diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 2923f741..f66ab571 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.28.36", + "version": "2.28.37", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/service/server.ts b/packages/hydrooj/src/service/server.ts index f9710887..102de8f2 100644 --- a/packages/hydrooj/src/service/server.ts +++ b/packages/hydrooj/src/service/server.ts @@ -619,10 +619,10 @@ export class Handler extends HandlerCommon { async onerror(error: HydroError) { if (!error.msg) error.msg = () => error.message; - if (error instanceof UserFacingError) error.stack = ''; + if (error instanceof UserFacingError && !process.env.DEV) error.stack = ''; if (!(error instanceof NotFoundError)) { - logger.error(this.request.path, error.msg(), error.params); - logger.error(error.stack); + logger.error(`User: ${this.user._id}(${this.user.uname}) Path: ${this.request.path}`, error.msg(), error.params); + if (error.stack) logger.error(error.stack); } this.response.status = error instanceof UserFacingError ? error.code : 500; this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html'; @@ -757,7 +757,10 @@ export class ConnectionHandler extends HandlerCommon { onerror(err: HydroError) { if (err instanceof UserFacingError) err.stack = this.conn.pathname; - if (!(err instanceof NotFoundError)) logger.error(err); + if (!(err instanceof NotFoundError)) { + logger.error(`Path:${this.conn.pathname}, User:${this.user._id}(${this.user.uname})`); + logger.error(err); + } this.send({ error: { name: err.name,