continue-custom/core/util/errors.ts
Nate 184be8f092 npx prettier --check "core/**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-p
ath .gitignore --ignore-path .prettierignore --write
2025-05-25 18:34:39 -07:00

12 lines
389 B
TypeScript

/**
* Recursively retrieves the root cause of an error by traversing through its `cause` property.
*
* @param err - The error object to analyze. It can be of any type.
* @returns The root cause of the error, or the original error if no further cause is found.
*/
export function getRootCause(err: any): any {
if (err.cause) {
return getRootCause(err.cause);
}
return err;
}