You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, while testing some functionnalities, I met an error that was not handled by dispatch_msg.
Indeed, if there is a test inside the constructor of some parameter of the call, like an @assert this errors, and breaks the JSONRPC communication because it does not return a JSONRPCError that could be properly handler later on.
The implementation below catches any error occurring during that step.
Do you think this could be a relevant addition ?
function JSONRPC.dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg::Request)
dispatcher._currentlyHandlingMsg =truetry
method_name = msg.method
handler =get(dispatcher._handlers, method_name, nothing)
if handler !==nothing
param_type =get_param_type(handler.message_type)
params =try
param_type === Nothing ?nothing: param_type <:NamedTuple?convert(param_type, (; (Symbol(i[1]) => i[2] for i in msg.params)...)) :param_type(msg.params)
catch ex
# Return an error if the conversion to the requested type fails for some reasonJSONRPCError(-999999, "Conversion error", nothing)
endif handler.message_type isa RequestType
handler.func(x, params, msg.token)
else
handler.func(x, params)
endif handler.message_type isa RequestType
if res isa JSONRPCError
send_error_response(x, msg, res.code, res.msg, res.data)
elseif res isaget_return_type(handler.message_type)
send_success_response(x, msg, res)
else
error_msg ="The handler for the '$method_name' request returned a value of type $(typeof(res)), which is not a valid return type according to the request definition."send_error_response(x, msg, -32603, error_msg, nothing)
error(error_msg)
endendelseerror("Unknown method $method_name.")
endfinally
dispatcher._currentlyHandlingMsg =falseendend
The text was updated successfully, but these errors were encountered:
BambOoxX
changed the title
Missing error handling case in
Missing error handling case in dispatch_msgJan 21, 2025
Hi, while testing some functionnalities, I met an error that was not handled by
dispatch_msg
.Indeed, if there is a test inside the constructor of some parameter of the call, like an
@assert
this errors, and breaks the JSONRPC communication because it does not return aJSONRPCError
that could be properly handler later on.The implementation below catches any error occurring during that step.
Do you think this could be a relevant addition ?
The text was updated successfully, but these errors were encountered: