*If an error, return it as a RPCResponse object instead of throwing an error
This commit is contained in:
parent
7916f6e4d6
commit
f4cb988053
|
@ -1,5 +1,5 @@
|
||||||
import { ErrTuple } from "libskynet";
|
import { ErrTuple } from "libskynet";
|
||||||
import type { RPCRequest } from "@lumeweb/relay-types";
|
import type { RPCRequest, RPCResponse } from "@lumeweb/relay-types";
|
||||||
import {
|
import {
|
||||||
RpcQueryOptions,
|
RpcQueryOptions,
|
||||||
StreamHandlerFunction,
|
StreamHandlerFunction,
|
||||||
|
@ -169,10 +169,10 @@ export abstract class RpcQueryBase {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
get result(): Promise<any> {
|
get result(): Promise<RPCResponse> {
|
||||||
return (this._promise as Promise<any>).then((result) => {
|
return (this._promise as Promise<any>).then((result): RPCResponse => {
|
||||||
if (result[1]) {
|
if (result[1]) {
|
||||||
throw new Error(result[1]);
|
return { error: result[1] };
|
||||||
}
|
}
|
||||||
return result[0];
|
return result[0];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue