UNPKG

@visulima/error

Version:

Error with more than just a message, stacktrace parsing.

46 lines (42 loc) 1.19 kB
'use strict'; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const isVisulimaError = /* @__PURE__ */ __name((error) => error instanceof Error && error.type === "VisulimaError", "isVisulimaError"); class VisulimaError extends Error { static { __name(this, "VisulimaError"); } loc; title; /** * A message that explains to the user how they can fix the error. */ hint; type = "VisulimaError"; constructor({ cause, hint, location, message, name, stack, title }) { super(message, { cause }); this.title = title; this.name = name; this.stack = stack ?? this.stack; this.loc = location; this.hint = hint; Error.captureStackTrace(this, this.constructor); } setLocation(location) { this.loc = location; } setName(name) { this.name = name; } setMessage(message) { this.message = message; } setHint(hint) { this.hint = hint; } } exports.VisulimaError = VisulimaError; exports.isVisulimaError = isVisulimaError;