We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf7c27b commit 1cbee39Copy full SHA for 1cbee39
src/common/exceptions/exception.ts
@@ -29,8 +29,10 @@ export const hasPrevious = (e: Error): e is Error & { previous: Error } =>
29
export function getPreviousList(ex: Error, includeSelf: boolean) {
30
const previous: Error[] = includeSelf ? [ex] : [];
31
let current = ex;
32
- while (hasPrevious(current)) {
33
- current = current.previous;
+ while (current.cause instanceof Error || hasPrevious(current)) {
+ current = hasPrevious(current)
34
+ ? current.previous
35
+ : (current.cause as Error);
36
previous.push(current);
37
}
38
return previous;
0 commit comments