diff options
author | MacroFake <falke.marco@gmail.com> | 2022-11-14 12:08:47 +0100 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-11-14 12:09:06 +0100 |
commit | 48174c0f287b19931ca110670610bd03a03eb914 (patch) | |
tree | 96fb96537719de24d3ef6c1bb76bdea483e3752b /src | |
parent | 59e00c7e03107e7d2582a0c14431bb4e62cccd77 (diff) | |
parent | 2dede9f67596787e18904d3d5961f48ec75f241e (diff) |
Merge bitcoin/bitcoin#26240: rpc: Adjust RPCTypeCheckObj error string
2dede9f67596787e18904d3d5961f48ec75f241e Adjust RPCTypeCheckObj error string (Leonardo Araujo)
Pull request description:
Unifies the JSON type error strings as mentioned in #26214. Also refer to #25737.
ACKs for top commit:
furszy:
ACK 2dede9f6
Tree-SHA512: c918889e347ba32cb6d0e33c0de5956c2077dd40c996151e16741b0c4983ff098c60258206ded76ad7bbec4876c780c6abb494a97e4f1e05717d28a59b9167a6
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/util.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 3e98e89791..dd5739faf7 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -65,11 +65,8 @@ void RPCTypeCheckObj(const UniValue& o, if (!fAllowNull && v.isNull()) throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first)); - if (!(t.second.typeAny || v.type() == t.second.type || (fAllowNull && v.isNull()))) { - std::string err = strprintf("Expected type %s for %s, got %s", - uvTypeName(t.second.type), t.first, uvTypeName(v.type())); - throw JSONRPCError(RPC_TYPE_ERROR, err); - } + if (!(t.second.typeAny || v.type() == t.second.type || (fAllowNull && v.isNull()))) + throw JSONRPCError(RPC_TYPE_ERROR, strprintf("JSON value of type %s for field %s is not of expected type %s", uvTypeName(v.type()), t.first, uvTypeName(t.second.type))); } if (fStrict) |