mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
framework: fix unwrapAggregatedError
This commit is contained in:
1 parent
73b2e4d75d
commit
a7a49bf791
4 files changed
+12
-8
No files matched your search
@@ -170,8 +170,15 @@ export const Time = {
|
||||
},
|
||||
};
|
||||
|
||||
export function unwrapAggregateError(error: any): any {
|
||||
return error instanceof Error && Array.isArray((error as any).errors) && (error as any).errors.length
|
||||
? unwrapAggregateError((error as any).errors[0])
|
||||
: error;
|
||||
}
|
||||
|
||||
export function errorMessage(err: Error | string) {
|
||||
const t = typeof err === 'string' ? err : err.stack;
|
||||
err = unwrapAggregateError(err);
|
||||
const t = typeof err === 'string' ? err : err.stack || err.message || String(err);
|
||||
const lines = t.split('\n')
|
||||
.filter((i) => !i.includes(' (node:') && !i.includes('(internal'));
|
||||
let cursor = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/utils",
|
||||
"version": "1.5.7",
|
||||
"version": "1.5.8",
|
||||
"description": "hydrooj utils",
|
||||
"type": "module",
|
||||
"main": "lib/utils.ts",
|
||||
|
||||
Reference in new issue
Block a user