epee: further defending against exceptions in command handlers
This commit is contained in:
parent
c9aad8a38b
commit
03254742e5
|
@ -290,6 +290,7 @@ namespace epee
|
||||||
#define BEGIN_INVOKE_MAP2(owner_type) \
|
#define BEGIN_INVOKE_MAP2(owner_type) \
|
||||||
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
|
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
|
||||||
{ \
|
{ \
|
||||||
|
try { \
|
||||||
typedef owner_type internal_owner_type_name;
|
typedef owner_type internal_owner_type_name;
|
||||||
|
|
||||||
#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out) \
|
#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out) \
|
||||||
|
@ -335,7 +336,13 @@ namespace epee
|
||||||
LOG_ERROR("Unknown command:" << command); \
|
LOG_ERROR("Unknown command:" << command); \
|
||||||
on_levin_traffic(context, false, false, true, in_buff.size(), "invalid-command"); \
|
on_levin_traffic(context, false, false, true, in_buff.size(), "invalid-command"); \
|
||||||
return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED; \
|
return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED; \
|
||||||
|
} \
|
||||||
|
catch (const std::exception &e) { \
|
||||||
|
MERROR("Error in handle_invoke_map: " << e.what()); \
|
||||||
|
return LEVIN_ERROR_CONNECTION_TIMEDOUT; /* seems kinda appropriate */ \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue