File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export class ChainError<T extends ObjectAny = ObjectAny> extends Error {
99 * Indicates that the new error was caused by `cause`. See `getCause()` below.
1010 * If unspecified, the cause will be `null`.
1111 */
12- override readonly cause ?: Error ;
12+ declare cause ?: Error ;
1313 /**
1414 * Specifies arbitrary informational properties that
1515 * are available through the `ChainError.getInfo(err)` static class method.
@@ -56,7 +56,9 @@ export class ChainError<T extends ObjectAny = ObjectAny> extends Error {
5656 * If we've been given a cause, record a reference to it and update our
5757 * message appropriately.
5858 */
59- this . cause = options . cause ;
59+ if ( options . cause ) {
60+ this . cause = options . cause ;
61+ }
6062 if ( this . cause && ! skipCauseMessage ) {
6163 this . message += ': ' + this . cause . message ;
6264 }
@@ -154,7 +156,7 @@ export class ChainError<T extends ObjectAny = ObjectAny> extends Error {
154156 * Returns a string containing the full stack trace, with all nested errors recursively
155157 * reported as `'caused by:' + err.stack`.
156158 */
157- static getFullStack ( err : { cause ?: unknown , stack ?: string } ) : string | undefined {
159+ static getFullStack ( err : { cause ?: unknown ; stack ?: string } ) : string | undefined {
158160 const cause = err . cause ;
159161 if ( cause ) {
160162 return err . stack + '\ncaused by: ' + this . getFullStack ( cause ) ;
You can’t perform that action at this time.
0 commit comments