예제 #1
0
 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);
 }
예제 #2
0
        public static JsonRpcException RpcGetAndRemoveRpcException()
        {
            var ex = __currentRpcException;

            __currentRpcException = null;
            return(ex);
        }
예제 #3
0
 internal JsonRpcException ProcessParseException(string req, JsonRpcException ex)
 {
     if (parseErrorHandler != null)
     {
         return(parseErrorHandler(req, ex));
     }
     return(ex);
 }
예제 #4
0
 private JsonRpcException ProcessException(JsonRequest req, JsonRpcException ex)
 {
     if (externalErrorHandler != null)
     {
         return(externalErrorHandler(req, ex));
     }
     return(ex);
 }
예제 #5
0
 /// <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.");
     }
 }
예제 #6
0
        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);
        }
예제 #7
0
 internal JsonRpcException ProcessParseException(string req,JsonRpcException ex)
 {
     if (parseErrorHandler != null)
         return parseErrorHandler(req, ex);
     return ex;
 }
예제 #8
0
 private JsonRpcException ProcessException(JsonRequest req,JsonRpcException ex)
 {
     if(externalErrorHandler!=null)
         return externalErrorHandler(req,ex);
     return ex;
 }
예제 #9
0
 /// <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.");
 }
예제 #10
0
 /// <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);
 }
예제 #11
0
 private string StringToRefException(string s, ref JsonRpcException refException)
 {
     refException = new JsonRpcException(-1, "refException worked", null);
     return s;
 }
예제 #12
0
 private string throwsException(string s, ref JsonRpcException refException)
 {
     refException = new JsonRpcException(-1, "This exception was thrown using: ref JsonRpcException", null);
     return s;
 }
예제 #13
0
 /// <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;
 }
예제 #14
0
 private AustinHarris.JsonRpc.JsonRpcException OnJsonRpcException(AustinHarris.JsonRpc.JsonRequest rpc, AustinHarris.JsonRpc.JsonRpcException ex)
 {
     return(ex);
 }
예제 #15
0
 /// <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);
 }