MCPcopy Create free account
hub / github.com/LUX-Core/lux / JSONErrorReply

Function JSONErrorReply

src/httprpc.cpp:64–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62static HTTPRPCTimerInterface* httpRPCTimerInterface = 0;
63
64static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const UniValue& id)
65{
66 // Send error reply from json-rpc error object
67 int nStatus = HTTP_INTERNAL_SERVER_ERROR;
68 int code = find_value(objError, "code").get_int();
69
70 if (code == RPC_INVALID_REQUEST)
71 nStatus = HTTP_BAD_REQUEST;
72 else if (code == RPC_METHOD_NOT_FOUND)
73 nStatus = HTTP_NOT_FOUND;
74
75 std::string strReply = JSONRPCReply(NullUniValue, objError, id);
76
77 if (req->isChunkMode()) {
78 // in chunk mode, we assume that the handler had already set the response content-type
79 req->Chunk(strReply);
80 req->ChunkEnd();
81 } else {
82 req->WriteHeader("Content-Type", "application/json");
83 req->WriteReply(nStatus, strReply);
84 }
85}
86
87static bool RPCAuthorized(const std::string& strAuth)
88{

Callers 1

HTTPReq_JSONRPCFunction · 0.85

Calls 7

JSONRPCReplyFunction · 0.85
isChunkModeMethod · 0.80
ChunkMethod · 0.80
ChunkEndMethod · 0.80
WriteHeaderMethod · 0.80
WriteReplyMethod · 0.80
get_intMethod · 0.45

Tested by

no test coverage detected