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]; });