Skip to content

Commit 10333f7

Browse files
committed
fix(api): add error handler in call hook handlers
1 parent d488511 commit 10333f7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/app-backend-api/src/hooks.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ export class DevtoolsHookable implements Hookable<BackendContext> {
2929
if (this.handlers[eventType]) {
3030
const handlers = this.handlers[eventType] as HookHandlerData<HookPayloads[T]>[]
3131
for (let i = 0; i < handlers.length; i++) {
32-
const { handler } = handlers[i]
33-
await handler(payload, ctx)
32+
const { handler, plugin } = handlers[i]
33+
try {
34+
await handler(payload, ctx)
35+
} catch (e) {
36+
console.error(`An error occured in hook ${eventType}${plugin ? ` registered by plugin ${plugin.descriptor.id}` : ''}`)
37+
console.error(e)
38+
}
3439
}
3540
}
3641
return payload

0 commit comments

Comments
 (0)