MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / JSONErrorReply

Function JSONErrorReply

src/httprpc.cpp:81–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79static bool g_rpc_whitelist_default = false;
80
81static void JSONErrorReply(HTTPRequest *req, const UniValue &objError,
82 const UniValue &id) {
83 // Send error reply from json-rpc error object.
84 int nStatus = HTTP_INTERNAL_SERVER_ERROR;
85 int code = objError.find_value("code").getInt<int>();
86
87 if (code == RPC_INVALID_REQUEST) {
88 nStatus = HTTP_BAD_REQUEST;
89 } else if (code == RPC_METHOD_NOT_FOUND) {
90 nStatus = HTTP_NOT_FOUND;
91 }
92
93 std::string strReply = JSONRPCReply(NullUniValue, objError, id);
94
95 req->WriteHeader("Content-Type", "application/json");
96 req->WriteReply(nStatus, strReply);
97}
98
99/*
100 * This function checks username and password against -rpcauth entries from

Callers 1

ProcessHTTPRequestMethod · 0.85

Calls 3

JSONRPCReplyFunction · 0.85
WriteHeaderMethod · 0.80
WriteReplyMethod · 0.80

Tested by

no test coverage detected