UNPKG

verror-0

Version:

VError without dependencies on top of nodejs standart library

18 lines (17 loc) 523 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.errorForEach = void 0; const is_error_js_1 = require("./is-error.js"); const multi_error_js_1 = require("./multi-error.js"); const errorForEach = (err, cb) => { if (!(0, is_error_js_1.isError)(err)) { throw new Error('err must be an Error'); } if (err instanceof multi_error_js_1.MultiError) { err.errors().forEach((e) => cb(e)); } else { cb(err); } }; exports.errorForEach = errorForEach;