getblockhash: throw JSONRPCError (not runtime_error) #5134

pull dexX7 wants to merge 1 commits into bitcoin:master from dexX7:getblockhash-jsonrpcerror changing 1 files +1 −1
  1. dexX7 commented at 1:45 PM on October 24, 2014: contributor

    No description provided.

  2. gavinandresen commented at 2:43 PM on October 24, 2014: contributor

    untested ACK

  3. laanwj commented at 2:44 PM on October 24, 2014: member

    uTACK

  4. laanwj added the label RPC on Oct 24, 2014
  5. getblockhash: throw JSONRPCError (not runtime_error) 6261e6e6e0
  6. in src/rpcblockchain.cpp:None in 806dea25ac outdated
     224 | @@ -225,7 +225,7 @@ Value getblockhash(const Array& params, bool fHelp)
     225 |  
     226 |      int nHeight = params[0].get_int();
     227 |      if (nHeight < 0 || nHeight > chainActive.Height())
     228 | -        throw runtime_error("Block number out of range.");
     229 | +        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block height out of range");
    


    sipa commented at 5:03 PM on October 24, 2014:

    I'd use RPC_INVALID_PARAMETER.


    dexX7 commented at 5:19 PM on October 24, 2014:

    I tend to agree due to the missing relation to an address or key.

    My understanding was that RPC_INVALID_PARAMETER is used for truely invalid input such as a sighash mode that doesn't exist whereby RPC_INVALID_ADDRESS_OR_KEY seems to be used for "invalid at this point" inputs ("block not found", "no information available about transaction"), but it's not 100 % consistent.

  7. dexX7 force-pushed on Oct 24, 2014
  8. laanwj merged this on Oct 27, 2014
  9. laanwj closed this on Oct 27, 2014

  10. laanwj referenced this in commit 2ffdf21ce3 on Oct 27, 2014
  11. dexX7 deleted the branch on Nov 7, 2014
  12. MarcoFalke 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-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me