Esempio n. 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);
 }
Esempio n. 2
0
        public static JsonRpcException RpcGetAndRemoveRpcException()
        {
            var ex = __currentRpcException;

            __currentRpcException = null;
            return(ex);
        }
Esempio n. 3
0
 internal JsonRpcException ProcessParseException(string req, JsonRpcException ex)
 {
     if (parseErrorHandler != null)
     {
         return(parseErrorHandler(req, ex));
     }
     return(ex);
 }
Esempio n. 4
0
 private JsonRpcException ProcessException(JsonRequest req, JsonRpcException ex)
 {
     if (externalErrorHandler != null)
     {
         return(externalErrorHandler(req, ex));
     }
     return(ex);
 }
Esempio n. 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.");
     }
 }
Esempio n. 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);
        }
Esempio n. 7
0
 internal JsonRpcException ProcessParseException(string req,JsonRpcException ex)
 {
     if (parseErrorHandler != null)
         return parseErrorHandler(req, ex);
     return ex;
 }
Esempio n. 8
0
 private JsonRpcException ProcessException(JsonRequest req,JsonRpcException ex)
 {
     if(externalErrorHandler!=null)
         return externalErrorHandler(req,ex);
     return ex;
 }
Esempio n. 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.");
 }
Esempio n. 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);
 }
Esempio n. 11
0
 private string StringToRefException(string s, ref JsonRpcException refException)
 {
     refException = new JsonRpcException(-1, "refException worked", null);
     return s;
 }
Esempio n. 12
0
 private string throwsException(string s, ref JsonRpcException refException)
 {
     refException = new JsonRpcException(-1, "This exception was thrown using: ref JsonRpcException", null);
     return s;
 }
Esempio n. 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;
 }
Esempio n. 14
0
 private AustinHarris.JsonRpc.JsonRpcException OnJsonRpcException(AustinHarris.JsonRpc.JsonRequest rpc, AustinHarris.JsonRpc.JsonRpcException 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 to function.
 /// </summary>
 /// <param name="exception"></param>
 public static void SetException(JsonRpcException exception)
 {
     Handler.RpcSetException(exception);
 }