All files / globals errors.ts

100% Statements 8/8
0% Branches 0/2
100% Functions 2/2
100% Lines 8/8

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        94x         94x         94x   169x 169x             94x   1x 1x      
/**
 * @module Errors
 */
 
import { LOG_PREFIX } from "@lisn/globals/minification-constants";
 
/**
 * Base error type emitted by LISN.
 */
export abstract class LisnError extends Error {}
 
/**
 * Error type emitted for invalid input or incorrect usage of a function.
 */
export class LisnUsageError extends LisnError {
  constructor(message = "") {
    super(`${LOG_PREFIX} Incorrect usage: ${message}`);
    this.name = "LisnUsageError";
  }
}
 
/**
 * Error type emitted if an assertion is wrong => report bug.
 */
export class LisnBugError extends LisnError {
  constructor(message = "") {
    super(`${LOG_PREFIX} Please report a bug: ${message}`);
    this.name = "LisnBugError";
  }
}