File size: 566 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as util from 'node:util';

export class JobDetailedError extends Error {
  originalError: unknown;

  constructor(err: unknown) {
    const inspected = util.inspect(err, {
      showHidden: false,
      depth: 2,
      colors: false,
    });
    super(inspected);
    this.name = 'JobDetailedError';
    this.originalError = err;

    // Ensure the stack trace is captured properly
    if (err instanceof Error && err.stack) {
      this.stack = `${this.name}:\n${inspected}`;
    } else {
      Error.captureStackTrace(this, this.constructor);
    }
  }
}