UNPKG

verror-0

Version:

VError without dependencies on top of nodejs standart library

17 lines (16 loc) 498 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stack = void 0; const cause_js_1 = require("./cause.js"); const is_error_js_1 = require("./is-error.js"); const stack = (err) => { if (!(0, is_error_js_1.isError)(err)) { throw new Error('err must be an Error'); } const c = (0, cause_js_1.cause)(err); if (c) { return err.stack + '\ncaused by: ' + (0, exports.stack)(c); } return err.stack ?? ''; }; exports.stack = stack;