Elffuss BraidHub

kikocis/continue public

ed46f5b1432f · 397 BRawPermalink
1
2/**
3 * Recursively retrieves the root cause of an error by traversing through its `cause` property.
4 *
5 * @param err - The error object to analyze. It can be of any type.
6 * @returns The root cause of the error, or the original error if no further cause is found.
7 */
8export function getRootCause(err: any): any {
9 if (err.cause) {
10 return getRootCause(err.cause);
11 }
12 return err;
13}