*Add error to RPCResponse, dont put inside data

This commit is contained in:
Derrick Hammer 2022-08-22 11:45:51 -04:00
parent b37b3052ec
commit 1a9f08cbba
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 8 deletions

View File

@ -49,11 +49,8 @@ interface RPCRequest {
interface RPCResponse {
updated: number;
data:
| any
| {
error: string | boolean;
};
data: any;
error?: string;
}
function hash(data: string): string {
@ -137,9 +134,11 @@ async function processRequest(request: RPCRequest): Promise<RPCResponse> {
}
}
dbData.data = error
? { error }
: (rpcResp as unknown as JSONRPCResponseWithResult).result;
if (error) {
dbData.error = error as string;
} else {
dbData.data = (rpcResp as unknown as JSONRPCResponseWithResult).result;
}
if (
(!processedRequests.get(reqId) || request.bypassCache) &&