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GAAK,CACd,CACF,CAEA,SAAS,YAAY,EAAU,GAC7B,GAAK,EAEL,OAAI,GAAY,EAAG,OAAS,EAAG,KAAa,EAAG,KAAK,QAE7C,EAAG,OACZ,CA5OA,OAAO,QAAU","file":"/npm/eraro@3.0.1/eraro.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/eraro@3.0.1/eraro.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* Copyright (c) 2014-2023 Richard Rodger, MIT License */\n/* jshint node:true, asi:true, eqnull:true */\n\n// Create JavaScript Error objects with code strings, context details,\n// and templated messages.\n'use strict'\n\n// #### System modules\nconst Util = require('util')\n\n// #### Exports\nmodule.exports = eraro\n\n// #### Create an _eraro_ function\n// Parameters:\n//\n//   * _options_ : (optional) Object; properties:\n//      * _package_ : (optional) String; package name to mark Error objects\n//      * _prefix_  : (optional) Boolean/String; If false, then no prefix is used; If not defined, the package name is used\n//      * _module_  : (optional) Object; _module_ object to use as starting point for _require_ calls\n//      * _msgmap_  : (optional) Object; map codes to message templates\n//      * _inspect_ : (optional) Boolean; If true, _Util.inspect_ is called on values; default: true.\n//\n// Returns: Function\n//\n// The created function has parameters:\n//\n//   * _exception_ : (optional) Error; the original exception to be wrapped\n//   * _code_ : (optional) String; code value\n//   * _message_ : (optional) String; error message, will be processed as a template\n//   * _details_ : (optional) Object; contextual details of the error, used to insert details into message\n//\n// and returns an Error object (to be thrown or used in a callback, as needed).\n// The returned Error object has the following additional properties:\n//\n//   * _code_: String; the code string\n//   * _package_: String; the package name\n//   * _**package-name**_: Boolean (true); a convenience marker for the package\n//   * _msg_: String; the generated message, may differ from original exception message (if any)\n//   * _details_: Object; contextual details of error\n//   * _callpoint_: String; first line of stacktrace that is external to eraro and calling module\nfunction eraro(options) {\n  options = options || {}\n\n  const msgprefix =\n    false === options.prefix\n      ? ''\n      : 'string' === typeof options.prefix\n      ? options.prefix\n      : 'string' === typeof options.package\n      ? options.package + ': '\n      : ''\n\n  const pkg = options.package || 'unknown'\n  const callmodule = options.module || module\n  const msgmap = options.msgmap || {}\n  const inspect = null == options.inspect ? true : !!options.inspect\n\n  const markers = [module.filename]\n\n  const filename = callmodule.filename\n  if (filename) {\n    markers.push(filename)\n  }\n\n  const errormaker = function (ex, code, msg, details) {\n    if (Util.isError(ex)) {\n      if (ex.eraro && !options.override) {\n        return ex\n      }\n    } else {\n      ex = null\n      code = arguments[0]\n      msg = arguments[1]\n      details = arguments[2]\n    }\n\n    code =\n      'string' === typeof code\n        ? code\n        : ex\n        ? ex.code\n          ? ex.code\n          : ex.message\n          ? ex.message\n          : 'unknown'\n        : 'unknown'\n\n    details =\n      'object' === typeof details ? details : 'object' === typeof msg ? msg : {}\n\n    if (ex) {\n      details.errmsg = ex.message\n      details.errline = callpoint(ex, markers)\n    }\n\n    msg = 'string' === typeof msg ? msg : null\n    msg = buildmessage(\n      options,\n      msg,\n      msgmap,\n      msgprefix,\n      inspect,\n      code,\n      details,\n      ex,\n    )\n\n    const err = new Error(msg)\n\n    if (ex) {\n      details.orig$ = null == details.orig$ ? ex : details.orig$\n      details.message$ =\n        null == details.message$ ? ex.message : details.message$\n\n      // drag along properties from original exception\n      for (const p in ex) {\n        err[p] = ex[p]\n      }\n    }\n\n    err.eraro = true\n\n    err.orig = ex // orig\n    err.code = code\n    err[pkg] = true\n    err.package = pkg\n    err.msg = msg\n    err.details = details\n\n    err.stack = ex ? ex.stack : err.stack\n    err.callpoint = details.errline || callpoint(err, markers)\n\n    return err\n  }\n\n  errormaker.callpoint = callpoint\n\n  errormaker.has = function (code) {\n    return !!msgmap[code]\n  }\n\n  return errormaker\n}\n\n// #### Find the first external stack trace line.\n// Parameters:\n//\n//   * _error_ : (optional) Error; provides the stack\n//   * _markers_ : (optional) Array[String]; ignore lines containing these strings\n//\n// Returns: String; stack trace line, with indent removed\nfunction callpoint(error, markers) {\n  markers = Array.isArray(markers) ? markers : []\n\n  const stack = error ? error.stack : null\n  let out = ''\n\n  if (stack) {\n    const lines = stack.split('\\n')\n    let i = 0\n\n    line_loop: for (i = 1; i < lines.length; i++) {\n      const line = lines[i]\n\n      let found = false\n      for (let j = 0; j < markers.length; j++) {\n        if ('string' === typeof markers[j]) {\n          found = -1 != line.indexOf(markers[j])\n          if (found) break\n        }\n      }\n\n      if (!found) break line_loop\n    }\n\n    out = 'string' === typeof lines[i] ? lines[i].substring(4) : out\n  }\n\n  return out\n}\n\n// #### Build the message string from a template by inserting details\n// Uses the underscore template function with default settings.\n// The original message (_msg_) has priority over messages from the _msgmap_.\n// If no message can be found, the _code_ is used as a message.\n// If an insert property is not defined, it is replaced with _[name?]_ in the message.\n// As a convenience, _util_ and ___ are made available in the templates.\n//\n// Parameters:\n//\n//   * _msg_ : (required) String; message template\n//   * _msgmap_ : (required) Object; map codes to message templates\n//   * _msgprefix_: (required) String; prefix for all messages, useful as indentification of error origin\n//   * _code_: (required) String; error code\n//   * _details_: (required) Object; error details providing context\n//\n// Returns: String; human readable error message\nfunction buildmessage(\n  options,\n  msg,\n  msgmap,\n  msgprefix,\n  _inspect,\n  code,\n  details,\n  ex,\n) {\n  let message =\n    msgprefix +\n    ('string' === typeof msg\n      ? msg\n      : 'string' === typeof msgmap[code]\n      ? msgmap[code]\n      : ex\n      ? originalmsg(options.override, ex)\n      : code)\n\n  // These are the inserts.\n  let valmap = Object.assign({}, details, { code: code })\n\n  message = message.replace(/<%=\\s*(.*?)\\s*%>/g, (m, p1) => {\n    let val = valmap[p1]\n    val = 'object' === typeof val && null != val ? stringify(val) : val\n\n    return val\n  })\n\n  return message\n}\n\nfunction stringify(val) {\n  try {\n    return JSON.stringify(val)\n      .substring(0, 111)\n      .replace(/([^\\\\])\"/g, '$1')\n  } catch (e) {\n    return '' + val\n  }\n}\n\nfunction originalmsg(override, ex) {\n  if (!ex) return\n\n  if (override && ex.eraro && ex.orig) return ex.orig.message\n\n  return ex.message\n}\n"]}