mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
framework: add default error log
This commit is contained in:
1 file changed
+2
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user