HomePhabricator

rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR

Description

rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR

Summary:

Throw a custom exception from Univalue::checkType (instead of a plain
std::runtime_error) and catch it on the RPC server request handler.

So we properly return RPC_TYPE_ERROR (-3) on every arg type error and
not the general RPC_MISC_ERROR (-1).

This will allow us to remove all the RPCTypeCheckArgument calls. As them are redundant since #25629.

Backport of core#25737.

Depends on D16289.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16290

Details

Provenance
furszy <matiasfurszyfer@protonmail.com>Authored on Sep 14 2022, 15:13
FabienCommitted on Thu, Jun 6, 09:26
FabienPushed on Thu, Jun 6, 09:26
Reviewer
Restricted Project
Differential Revision
D16290: rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR
Parents
rABC72a9f0336b08: univalue: Avoid std::string copies
Branches
Unknown
Tags
Unknown