Skip to the content

Capsid menu

render-error.mjs

21 lines and 2 functions in DrDustinEdwards/prelum, at commit e389900 on 2026-10-24. This file on GitHub.

Functions

The functions of render-error.mjs
FunctionLinesComplexityCoveredCRAPMutation
constructor8 to 121100%OkCRAP 1No data: mutation testing has not run on this repo yet
errorMessage21 to 232100%OkCRAP 2No data: mutation testing has not run on this repo yet

Imports

It imports no other module of this repo. Imported by render-conformance.mjs, render-directives.mjs, render-nomath.mjs, render-packs.mjs, render-safe.mjs, render.mjs.

Source

// Its own module so the directive plugins and the renderer throw the one class without importing each other.

export class ContentError extends Error {
  /**
   * @param {string} file
   * @param {string} message
   */
  constructor(file, message) {
    super(`${file}: ${message}`);
    this.name = "ContentError";
    this.file = file;
  }
}

/**
 * The message of a thrown value: an Error's own message, anything else as a string.
 *
 * @param {unknown} error
 * @returns {string}
 */
export function errorMessage(error) {
  return error instanceof Error ? error.message : String(error);
}