File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -158,20 +158,27 @@ Task<void> RequestHandler::handle_request(commands::RpcApiTable::HandleMethod ha
158158}
159159
160160Task<void > RequestHandler::handle_request (commands::RpcApiTable::HandleStream handler, const nlohmann::json& request_json) {
161- try {
162- auto io_executor = co_await boost::asio::this_coro::executor;
161+ auto io_executor = co_await boost::asio::this_coro::executor;
163162
163+ try {
164164 co_await channel_->open_stream ();
165165 ChunkWriter chunk_writer (*channel_);
166166 json::Stream stream (io_executor, chunk_writer);
167167
168- co_await (rpc_api_.*handler)(request_json, stream);
169-
168+ try {
169+ co_await (rpc_api_.*handler)(request_json, stream);
170+ } catch (const std::exception& e) {
171+ SILK_ERROR << " exception: " << e.what ();
172+ const auto error = make_json_error (request_json, 100 , e.what ());
173+ stream.write_json (error);
174+ } catch (...) {
175+ SILK_ERROR << " unexpected exception" ;
176+ const auto error = make_json_error (request_json, 100 , " unexpected exception" );
177+ stream.write_json (error);
178+ }
170179 co_await stream.close ();
171180 } catch (const std::exception& e) {
172181 SILK_ERROR << " exception: " << e.what ();
173- } catch (...) {
174- SILK_ERROR << " unexpected exception" ;
175182 }
176183
177184 co_return ;
You can’t perform that action at this time.
0 commit comments