protected virtual object OnError(Exception e, IDictionary request) { if (JsonRpcTrace.Switch.TraceError) { JsonRpcTrace.Error(e); } return(JsonRpcError.FromException(e, LocalExecution)); }
public void StackTraceInclusion() { ApplicationException exception = new ApplicationException(); JsonObject error = JsonRpcError.FromException(ThrowAndCatch(exception), true); string trace = (string)error["stackTrace"]; Assert.IsNotNull(trace); Assert.IsNotEmpty(trace); }
public void InnerExceptions() { Exception inner = new FormatException(); ApplicationException outer = new ApplicationException(null, inner); JsonObject error = JsonRpcError.FromException(ThrowAndCatch(outer)); JsonArray errors = (JsonArray)error["errors"]; Assert.AreEqual(2, errors.Count); error = (JsonObject)errors.Shift(); Assert.AreEqual(outer.Message, error["message"]); Assert.AreEqual("ApplicationException", error["name"]); error = (JsonObject)errors.Shift(); Assert.AreEqual(inner.Message, error["message"]); Assert.AreEqual("FormatException", error["name"]); }
public void InitializationFromException() { ApplicationException exception = new ApplicationException(); JsonObject error = JsonRpcError.FromException(ThrowAndCatch(exception)); Assert.IsNotNull(error); Assert.AreEqual(3, error.Count); Assert.AreEqual(exception.Message, error["message"]); Assert.AreEqual("JSONRPCError", error["name"]); JsonArray errors = (JsonArray)error["errors"]; Assert.AreEqual(1, errors.Count); error = (JsonObject)errors.Shift(); Assert.AreEqual(exception.Message, error["message"]); Assert.AreEqual("ApplicationException", error["name"]); }