framework: add default error log

This commit is contained in:
undefined committed 2025-07-09 02:13:28 +08:00
1 parent dc6345c0b3
commit 9592679f98
1 file changed
+2
+2
View File
@@ -247,6 +247,7 @@ export class Handler<C = CordisContext> extends HandlerCommon<C> {
async onerror(error: HydroError) {
error.msg ||= () => error.message;
console.error(`Error on user request: ${error.msg()}\n`, error);
if (error instanceof UserFacingError && !process.env.DEV) error.stack = '';
this.response.status = error instanceof UserFacingError ? error.code : 500;
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
@@ -286,6 +287,7 @@ export class ConnectionHandler<C> extends HandlerCommon<C> {
onerror(err: HydroError) {
if (err instanceof UserFacingError) err.stack = this.request.path;
else console.error('Error on user websocket:', err);
this.send({
error: {
name: err.name,