private JsonResponse PostProcess(JsonRequest request, JsonResponse response, object context) { if (externalPostProcessingHandler != null) { try { JsonRpcException exception = externalPostProcessingHandler(request, response, context); if (exception != null) { response = new JsonResponse() { Error = exception }; } } catch (Exception ex) { response = new JsonResponse() { Error = ProcessException(request, new JsonRpcException(-32603, "Internal Error", ex)) }; } } return(response); }
public static JsonRpcException RpcGetAndRemoveRpcException() { var ex = __currentRpcException; __currentRpcException = null; return(ex); }
internal JsonRpcException ProcessParseException(string req, JsonRpcException ex) { if (parseErrorHandler != null) { return(parseErrorHandler(req, ex)); } return(ex); }
private JsonRpcException ProcessException(JsonRequest req, JsonRpcException ex) { if (externalErrorHandler != null) { return(externalErrorHandler(req, ex)); } return(ex); }
/// <summary> /// Allows you to set the exception used in in the JsonRpc response. /// Warning: Must be called from within the execution context of the jsonRpc method. /// </summary> /// <param name="exception"></param> public static void RpcSetException(JsonRpcException exception) { if (Task.CurrentId != null) { RpcExceptions[Task.CurrentId.Value] = exception; } else { throw new InvalidOperationException("This method is only valid when used within the context of a method marked as a JsonRpcMethod, and that method must of been invoked by the JsonRpc Handler."); } }
private JsonResponse PostProcess(Action <JsonResponse> callback, JsonRequest request, JsonResponse response, object context) { if (externalPostProcessingHandler != null) { JsonRpcException exception = externalPostProcessingHandler(request, response, context); if (exception != null) { response = new JsonResponse() { Error = exception }; } } if (callback != null) { callback.Invoke(response); } return(response); }
internal JsonRpcException ProcessParseException(string req,JsonRpcException ex) { if (parseErrorHandler != null) return parseErrorHandler(req, ex); return ex; }
private JsonRpcException ProcessException(JsonRequest req,JsonRpcException ex) { if(externalErrorHandler!=null) return externalErrorHandler(req,ex); return ex; }
/// <summary> /// Allows you to set the exception used in in the JsonRpc response. /// Warning: Must be called from within the execution context of the jsonRpc method. /// </summary> /// <param name="exception"></param> public static void RpcSetException(JsonRpcException exception) { if (Task.CurrentId != null) RpcExceptions[Task.CurrentId.Value] = exception; else throw new InvalidOperationException("This method is only valid when used within the context of a method marked as a JsonRpcMethod, and that method must of been invoked by the JsonRpc Handler."); }
/// <summary> /// Allows you to set the exception used in in the JsonRpc response. /// Warning: Must be called from within the execution context of the jsonRpc method to function. /// </summary> /// <param name="exception"></param> public static void SetException(JsonRpcException exception) { Handler.RpcSetException(exception); }
private string StringToRefException(string s, ref JsonRpcException refException) { refException = new JsonRpcException(-1, "refException worked", null); return s; }
private string throwsException(string s, ref JsonRpcException refException) { refException = new JsonRpcException(-1, "This exception was thrown using: ref JsonRpcException", null); return s; }
/// <summary> /// Allows you to set the exception used in in the JsonRpc response. /// Warning: Must be called from the same thread as the jsonRpc method. /// </summary> /// <param name="exception"></param> public static void RpcSetException(JsonRpcException exception) { __currentRpcException = exception; }
private AustinHarris.JsonRpc.JsonRpcException OnJsonRpcException(AustinHarris.JsonRpc.JsonRequest rpc, AustinHarris.JsonRpc.JsonRpcException ex) { return(ex); }