ForestAdmin/lumber

View on GitHub
utils/lumber-error.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class LumberError extends Error {
  /**
   * @param {string} message
   * @param {any} [details]
   * @param {{
   *  reason?: string;
   *  possibleSolution?: string;
   * }} [options]
   */
  constructor(message, details, options) {
    super(message);

    /** @public @readonly */
    this.name = 'LumberError';

    /** @public @readonly */
    this.userMessage = message;

    /** @public @readonly */
    this.details = details;

    /** @public @readonly */
    this.reason = options && options.reason;

    /** @public @readonly */
    this.possibleSolution = options && options.possibleSolution;

    Error.captureStackTrace(this, this.constructor);
  }
}

module.exports = LumberError;