From f4cb9880531209e5435bdc52babd396878b12297 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 30 Aug 2022 22:17:39 -0400 Subject: [PATCH] *If an error, return it as a RPCResponse object instead of throwing an error --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index c6476c7..e1d8df3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { ErrTuple } from "libskynet"; -import type { RPCRequest } from "@lumeweb/relay-types"; +import type { RPCRequest, RPCResponse } from "@lumeweb/relay-types"; import { RpcQueryOptions, StreamHandlerFunction, @@ -169,10 +169,10 @@ export abstract class RpcQueryBase { return this; } - get result(): Promise { - return (this._promise as Promise).then((result) => { + get result(): Promise { + return (this._promise as Promise).then((result): RPCResponse => { if (result[1]) { - throw new Error(result[1]); + return { error: result[1] }; } return result[0]; });