mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix aggregate error handle
This commit is contained in:
1 parent
11fc1f59c9
commit
9e08afbccd
2 files changed
+10
-5
No files matched your search
@@ -56,6 +56,10 @@ async function forkContextWithScope(ctx: CordisContext) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unwrapAggregateError(error: any) {
|
||||||
|
return error instanceof AggregateError ? error.errors[0] : error;
|
||||||
|
}
|
||||||
|
|
||||||
export interface HydroRequest {
|
export interface HydroRequest {
|
||||||
method: string;
|
method: string;
|
||||||
host: string;
|
host: string;
|
||||||
@@ -601,11 +605,12 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
} else current++;
|
} else current++;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
const error = unwrapAggregateError(e);
|
||||||
try {
|
try {
|
||||||
// FIXME: should pass type check
|
// FIXME: should pass type check
|
||||||
await (this.ctx.serial as any)(`handler/error/${name}`, h, e);
|
await (this.ctx.serial as any)(`handler/error/${name}`, h, error);
|
||||||
await (this.ctx.serial as any)('handler/error', h, e);
|
await (this.ctx.serial as any)('handler/error', h, error);
|
||||||
await h.onerror(e);
|
await h.onerror(error);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
h.response.status = 500;
|
h.response.status = 500;
|
||||||
@@ -726,7 +731,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// error during initialization (prepare, hooks)
|
// error during initialization (prepare, hooks)
|
||||||
await clean(e);
|
await clean(unwrapAggregateError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "5.0.5",
|
"version": "5.0.6",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/plugin-api",
|
"main": "src/plugin-api",
|
||||||
"module": "src/plugin-api",
|
"module": "src/plugin-api",
|
||||||
|
|||||||
Reference in new issue
Block a user