Skip to content

Commit e7b9f4b

Browse files
committed
feat: 🎸 log internal errors
1 parent 10723c1 commit e7b9f4b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/server/routes/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import {routes} from './routes';
12
import {TypeSystem} from '../../json-type';
23
import {TypeRouter} from '../../json-type/system/TypeRouter';
34
import {TypeRouterCaller} from '../../reactive-rpc/common/rpc/caller/TypeRouterCaller';
4-
import {routes} from './routes';
5+
import {RpcError} from '../../reactive-rpc/common/rpc/caller';
56
import type {Services} from '../services/Services';
67
import type {RouteDeps} from './types';
78

@@ -14,6 +15,13 @@ export const createRouter = (services: Services) => {
1415

1516
export const createCaller = (services: Services) => {
1617
const router = createRouter(services);
17-
const caller = new TypeRouterCaller<typeof router>({router});
18+
const caller = new TypeRouterCaller<typeof router>({
19+
router,
20+
wrapInternalError: (error: unknown) => {
21+
if (error instanceof RpcError) console.error(error.toJson());
22+
else console.error(error);
23+
return RpcError.valueFrom(error);
24+
},
25+
});
1826
return caller;
1927
};

0 commit comments

Comments
 (0)