import { unixEOL } from './string-formatter' ; /**
 * Represents an error that was caused by another error.
 */ export class ErrorWithCause extends Error { param message param cause constructor ( message , public readonly cause ) { super ( message ) ; Object . setPrototypeOf ( this , new . target . prototype ) ; this . name = 'ErrorWithCause' ; if ( this . stack && cause ?. stack ) { this . stack = `${ this . stack }${ unixEOL }Caused by:${ unixEOL }${ cause . stack }` ; } } /**
     * 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.
     */ get rootCause ( ) : Error { return isErrorWithCause ( this . cause ) ? this . cause . rootCause : this . cause ; } } param err returns export function isErrorWithCause ( err ) { return err ?. name === 'ErrorWithCause' ; }