error.js 595 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Stringify = require('./stringify');
  3. const internals = {};
  4. module.exports = class extends Error {
  5. constructor(args) {
  6. const msgs = args
  7. .filter((arg) => arg !== '')
  8. .map((arg) => {
  9. return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);
  10. });
  11. super(msgs.join(' ') || 'Unknown error');
  12. if (typeof Error.captureStackTrace === 'function') { // $lab:coverage:ignore$
  13. Error.captureStackTrace(this, exports.assert);
  14. }
  15. }
  16. };