mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: dev模式下保留UserFacingError堆栈
This commit is contained in:
1 parent
71ebb3ffd6
commit
6607a36856
2 files changed
+8
-5
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user