Skip to content

Commit cb4f91c

Browse files
committed
Log callback error details if a callback throws an exception
This was always included in the response body, but sometimes that's not convenient. In general no callbacks should be intentionally throwing an error - if you want to send an error response, you should explicitly return that instead.
1 parent cc83fdf commit cb4f91c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/rules/requests/request-handlers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export class CallbackHandler extends CallbackHandlerDefinition {
205205
outResponse = await this.callback(req);
206206
} catch (error) {
207207
writeHead(response, 500, 'Callback handler threw an exception');
208+
console.warn(`Callback handler exception: ${(error as ErrorLike).message ?? error}`);
208209
response.end(isErrorLike(error) ? error.toString() : error);
209210
return;
210211
}

0 commit comments

Comments
 (0)