Alternative to #9112 ?
Return the type when it's unknown instead of throwing an exception #9113
pull rebroad wants to merge 1 commits into bitcoin:master from rebroad:ReturnNotThrow changing 1 files +1 −1-
rebroad commented at 10:25 AM on November 9, 2016: contributor
-
Return the type when it's unknown instead of throwing an exception f962a840be
-
in src/protocol.cpp:None in f962a840be
174 | @@ -175,7 +175,7 @@ std::string CInv::GetCommand() const 175 | case MSG_FILTERED_BLOCK: return cmd.append(NetMsgType::MERKLEBLOCK); 176 | case MSG_CMPCT_BLOCK: return cmd.append(NetMsgType::CMPCTBLOCK); 177 | default: 178 | - throw std::out_of_range(strprintf("CInv::GetCommand(): type=%d unknown type", type)); 179 | + return strprintf("0x%08x", type);
paveljanik commented at 10:26 AM on November 9, 2016:Or even
unknown(0x%08x)?paveljanik commented at 10:28 AM on November 9, 2016: contributorI prefer this solution because it fixes the cause - throwing the exception.
paveljanik cross-referenced this on Nov 9, 2016 from issue Avoid ugly exception in log on unknown inv type by laanwjfanquake added the label Docs and Output on Nov 9, 2016laanwj closed this on Nov 11, 2016bitcoin locked this on Sep 8, 2021
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:55 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:55 UTC