public static void Throw(ExecutionError error) { var description = error.GetType() .GetField(error.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false) .Cast <DescriptionAttribute>() .Single() .Description; throw new ExecutionException(description); }
private IValue populateError(ExecutionError e, Context context) { IExpression exp = e.getExpression(context); if (exp == null) { ArgumentList args = new ArgumentList(); args.Add(new Argument(new UnresolvedParameter("name"), new TextLiteral(e.GetType().Name))); args.Add(new Argument(new UnresolvedParameter("text"), new TextLiteral(e.Message))); ConstructorExpression ctor = new ConstructorExpression(new CategoryType("Error"), null, args); exp = ctor; } if (context.getRegisteredValue <INamed>(errorName) == null) { context.registerValue(new ErrorVariable(errorName)); } IValue value = exp.interpret(context); context.setValue(errorName, value); return(value); }