Skip to content

Commit

Permalink
Catch exceptions when calling http_fwd();
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Jul 4, 2023
1 parent 095e6ba commit 70442b3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions plugins/http_plugin/include/eosio/http_plugin/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@
_http_plugin.post_http_thread_pool([resp_code=http_resp_code, cb=std::move(cb), \
body=std::move(body), \
http_fwd = std::move(http_fwd)]() { \
chain::t_or_exception<call_result> result = http_fwd(); \
if (std::holds_alternative<fc::exception_ptr>(result)) { \
try { \
std::get<fc::exception_ptr>(result)->dynamic_rethrow_exception(); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
try { \
chain::t_or_exception<call_result> result = http_fwd(); \
if (std::holds_alternative<fc::exception_ptr>(result)) { \
try { \
std::get<fc::exception_ptr>(result)->dynamic_rethrow_exception(); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
} else { \
cb(resp_code, fc::variant(std::get<call_result>(std::move(result)))); \
} \
} else { \
cb(resp_code, fc::variant(std::get<call_result>(std::move(result)))); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
}); \
} catch (...) { \
Expand Down

0 comments on commit 70442b3

Please sign in to comment.