fix: improve error propagation in RpcService

This commit is contained in:
Ben Allfree
2023-06-19 08:37:24 -07:00
parent 6b48aee4c4
commit 2969de60ff

View File

@@ -12,7 +12,7 @@ import { isObject } from '@s-libs/micro-dash'
import Ajv, { JSONSchemaType, ValidateFunction } from 'ajv'
import Bottleneck from 'bottleneck'
import { default as knexFactory } from 'knex'
import pocketbaseEs from 'pocketbase'
import pocketbaseEs, { ClientResponseError } from 'pocketbase'
import { AsyncReturnType, JsonObject } from 'type-fest'
import { registerRpcCommands } from './commands'
@@ -88,7 +88,7 @@ export const rpcService = mkSingleton(async (config: RpcServiceConfig) => {
throw new Error(`Expected Error here but got ${typeof e}:${e}`)
}
dbg(`RPC failed with`, e)
await client.rejectRpc(rpc, e).catch((e) => {
await client.rejectRpc(rpc, new ClientResponseError(e)).catch((e) => {
error(`rpc ${rpc.id} failed to reject with ${e}`)
})
}