mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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 {
|
||||
method: string;
|
||||
host: string;
|
||||
@@ -601,11 +605,12 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
||||
} else current++;
|
||||
}
|
||||
} catch (e) {
|
||||
const error = unwrapAggregateError(e);
|
||||
try {
|
||||
// FIXME: should pass type check
|
||||
await (this.ctx.serial as any)(`handler/error/${name}`, h, e);
|
||||
await (this.ctx.serial as any)('handler/error', h, e);
|
||||
await h.onerror(e);
|
||||
await (this.ctx.serial as any)(`handler/error/${name}`, h, error);
|
||||
await (this.ctx.serial as any)('handler/error', h, error);
|
||||
await h.onerror(error);
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
h.response.status = 500;
|
||||
@@ -726,7 +731,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
||||
}
|
||||
} catch (e) {
|
||||
// error during initialization (prepare, hooks)
|
||||
await clean(e);
|
||||
await clean(unwrapAggregateError(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "5.0.5",
|
||||
"version": "5.0.6",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/plugin-api",
|
||||
"module": "src/plugin-api",
|
||||
|
||||
Reference in new issue
Block a user