public static string GetThrownExceptionMessage <TValue>(EvaluatorExceptionThrownException <TValue> exception, IStackFrame frame, IValueServicesFacade <TValue> valueServices, IValueFetchOptions valueFetchOptions, ILogger logger) where TValue : class { try { var reference = new SimpleValueReference <TValue>(exception.Exception, frame, valueServices.RoleFactory); return(reference.AsObjectSafe(valueFetchOptions) ?.GetInstancePropertyReference("Message", true) ?.AsStringSafe(valueFetchOptions)?.GetString()); } catch (Exception e) { // Argh! Exception thrown while trying to get information about a thrown exception! logger.LogExceptionSilently(e); return(null); } }
public static ObjectValue CreateEvaluationException(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, EvaluatorExceptionThrownException exception, ObjectValueFlags flags = ObjectValueFlags.None) { var error = CreateError (source, path, exception.ExceptionTypeName, "Exception was thrown", flags); var exceptionReference = LiteralValueReference.CreateTargetObjectLiteral (ctx, "Exception", exception.Exception); var exceptionValue = exceptionReference.CreateObjectValue (ctx.Options); error.children = new List<ObjectValue> {exceptionValue}; return error; }
public static ObjectValue CreateEvaluationException(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, EvaluatorExceptionThrownException exception, ObjectValueFlags flags = ObjectValueFlags.None) { var error = CreateError(source, path, exception.ExceptionTypeName, "Exception was thrown", flags); var exceptionReference = LiteralValueReference.CreateTargetObjectLiteral(ctx, "Exception", exception.Exception); var exceptionValue = exceptionReference.CreateObjectValue(ctx.Options); error.children = new List <ObjectValue> { exceptionValue }; return(error); }