@sap-cloud-sdk/util
Version:
SAP Cloud SDK for JavaScript general utilities
28 lines (27 loc) • 896 B
TypeScript
/**
* Represents an error that was caused by another error.
*/
export declare class ErrorWithCause extends Error {
readonly cause: Error;
/**
* Create an instance of ErrorWithCause.
* @param message - Error message.
* @param cause - Original error, causing this error.
*/
constructor(message: string, cause: Error);
private isAxiosError;
private addStack;
/**
* Root cause of the error.
* If there are multiple errors caused one by another, the root cause is the first error that occurred.
* In case there is no root cause.
* @returns The root cause.
*/
get rootCause(): Error;
}
/**
* Type guard to check whether an error is of type ErrorWithCause.
* @param err - An error.
* @returns Whether the given error is of type ErrorWithCause.
*/
export declare function isErrorWithCause(err: Error): err is ErrorWithCause;