All files / utils wrapped-error.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 131x         1x 1x 1x 1x 1x 1x    
export class WrappedError extends Error {
  public readonly originalError: Error
  public readonly originalStack?: string
 
  constructor(message: string, error: any){
    super(message)
    this.name = this.constructor.name
    this.originalError = error
    this.originalStack = super.stack
    const message_lines =  (this.message.match(/\n/g)||[]).length + 1
    this.stack = super.stack?.split('\n').slice(0, message_lines+1).join('\n') + '\n' + error.stack
  }
}