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