From 72aaa20f9bcfec2e2b1626693af6e8b151bb0c1a Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Thu, 28 May 2020 17:38:25 -0700 Subject: [PATCH 1/2] Fix a typo in the error handler case --- src/typed.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/typed.jl b/src/typed.jl index d35dc1d1..4e24c829 100644 --- a/src/typed.jl +++ b/src/typed.jl @@ -63,7 +63,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg) end catch err if err isa JSONRPCError - send_error_response(x, msg, err.code, err.message, err.data) + send_error_response(x, msg, err.code, err.msg, err.data) else rethrow(err) end From 52d8cd9f423b9cea3040eb86544257504aa6b97a Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Thu, 28 May 2020 17:45:19 -0700 Subject: [PATCH 2/2] Change how JSON RPC errors are handled --- src/typed.jl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/typed.jl b/src/typed.jl index 4e24c829..0cfffc52 100644 --- a/src/typed.jl +++ b/src/typed.jl @@ -52,20 +52,16 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg) method_name = msg["method"] handler = get(dispatcher._handlers, method_name, nothing) if handler !== nothing - try - param_type = get_param_type(handler.message_type) - params = param_type === Nothing ? nothing : param_type(msg["params"]) + param_type = get_param_type(handler.message_type) + params = param_type === Nothing ? nothing : param_type(msg["params"]) - res = handler.func(x, params) + res = handler.func(x, params) - if handler.message_type isa RequestType - send_success_response(x, msg, res) - end - catch err - if err isa JSONRPCError - send_error_response(x, msg, err.code, err.msg, err.data) + if handler.message_type isa RequestType + if res isa JSONRPCError + send_error_response(x, msg, res.code, res.msg, res.data) else - rethrow(err) + send_success_response(x, msg, res) end end else