All files / app/errors internal-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 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391x                                                 13x 3x   10x     13x   13x       1x  
import {RestError} from './rest-error';
 
/**
 * Error class for internal errors.
 */
class InternalError extends RestError {
  /**
   * The stack trace of the error.
   *
   * Should only be used in a non production setting.
   */
  public readonly stack?: string;
 
  /**
   * Creates an instance of this class.
   * @param message - Message of this error. Has fallback message.
   * @param detail  - Additional information
   * @param stack   - Stack information
   */
  constructor(
      message?: string,
      detail?: Record<string, unknown>,
      stack?: string,
  ) {
    let _message: string;
    if (message === undefined) {
      _message = 'An internal error occurred';
    } else {
      _message = message;
    }
 
    super(500, _message, detail);
 
    this.stack = stack;
  }
}
 
export default InternalError;