diff --git a/silkworm/rpc/commands/erigon_api.cpp b/silkworm/rpc/commands/erigon_api.cpp index 176fedd0c3..4cb4188e9d 100644 --- a/silkworm/rpc/commands/erigon_api.cpp +++ b/silkworm/rpc/commands/erigon_api.cpp @@ -256,6 +256,8 @@ Task ErigonRpcApi::handle_erigon_get_header_by_hash(const nlohmann::json& } else { reply = make_json_content(request, *header); } + } catch (const std::invalid_argument& iv) { + reply = make_json_error(request, kServerError, "block header not found: 0x" + silkworm::to_hex(block_hash)); } catch (const std::exception& e) { SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump(); reply = make_json_error(request, kInternalError, e.what()); @@ -423,6 +425,8 @@ Task ErigonRpcApi::handle_erigon_get_logs_by_hash(const nlohmann::json& re SILK_DEBUG << "logs.size(): " << logs.size(); reply = make_json_content(request, logs); + } catch (const std::invalid_argument& iv) { + reply = make_json_content(request, nullptr); } catch (const std::exception& e) { SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump(); reply = make_json_error(request, kInternalError, e.what()); diff --git a/silkworm/rpc/commands/eth_api.cpp b/silkworm/rpc/commands/eth_api.cpp index 25cb2093c9..c74b36a0d0 100644 --- a/silkworm/rpc/commands/eth_api.cpp +++ b/silkworm/rpc/commands/eth_api.cpp @@ -464,6 +464,8 @@ Task EthereumRpcApi::handle_eth_get_uncle_count_by_block_hash(const nlohma const auto ommers = block_with_hash->block.ommers.size(); reply = make_json_content(request, to_quantity(ommers)); } + } catch (const std::invalid_argument& iv) { + reply = make_json_content(request, nullptr); } catch (const std::exception& e) { SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump(); reply = make_json_error(request, kInternalError, e.what());