MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / JSONErrorReply

Function JSONErrorReply

src/httprpc.cpp:42–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40static bool g_rpc_whitelist_default = false;
41
42static UniValue JSONErrorReply(UniValue objError, const JSONRPCRequest& jreq, HTTPStatusCode& nStatus)
43{
44 // HTTP errors should never be returned if JSON-RPC v2 was requested. This
45 // function should only be called when a v1 request fails or when a request
46 // cannot be parsed, so the version is unknown.
47 Assume(jreq.m_json_version != JSONRPCVersion::V2);
48
49 // Send error reply from json-rpc error object
50 nStatus = HTTP_INTERNAL_SERVER_ERROR;
51 int code = objError.find_value("code").getInt<int>();
52
53 if (code == RPC_INVALID_REQUEST)
54 nStatus = HTTP_BAD_REQUEST;
55 else if (code == RPC_METHOD_NOT_FOUND)
56 nStatus = HTTP_NOT_FOUND;
57
58 return JSONRPCReplyObj(NullUniValue, std::move(objError), jreq.id, jreq.m_json_version);
59}
60
61//This function checks username and password against -rpcauth
62//entries from config file.

Callers 2

ExecuteHTTPRPCFunction · 0.85
HTTPReq_JSONRPCFunction · 0.85

Calls 1

JSONRPCReplyObjFunction · 0.85

Tested by

no test coverage detected