mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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",
|
"name": "hydrooj",
|
||||||
"version": "2.28.36",
|
"version": "2.28.37",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -619,10 +619,10 @@ export class Handler extends HandlerCommon {
|
|||||||
|
|
||||||
async onerror(error: HydroError) {
|
async onerror(error: HydroError) {
|
||||||
if (!error.msg) error.msg = () => error.message;
|
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)) {
|
if (!(error instanceof NotFoundError)) {
|
||||||
logger.error(this.request.path, error.msg(), error.params);
|
logger.error(`User: ${this.user._id}(${this.user.uname}) Path: ${this.request.path}`, error.msg(), error.params);
|
||||||
logger.error(error.stack);
|
if (error.stack) logger.error(error.stack);
|
||||||
}
|
}
|
||||||
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
||||||
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
||||||
@@ -757,7 +757,10 @@ export class ConnectionHandler extends HandlerCommon {
|
|||||||
|
|
||||||
onerror(err: HydroError) {
|
onerror(err: HydroError) {
|
||||||
if (err instanceof UserFacingError) err.stack = this.conn.pathname;
|
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({
|
this.send({
|
||||||
error: {
|
error: {
|
||||||
name: err.name,
|
name: err.name,
|
||||||
|
|||||||
Reference in new issue
Block a user