package.cjs.ApiDOMAggregateError.cjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apidom-error Show documentation
Show all versions of apidom-error Show documentation
Backward compatible custom ApiDOM errors with causes.
The newest version!
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _aggregateError = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/aggregate-error"));
class ApiDOMAggregateError extends _aggregateError.default {
constructor(errors, message, options) {
super(errors, message, options);
this.name = this.constructor.name;
if (typeof message === 'string') {
this.message = message;
}
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = new Error(message).stack;
}
/**
* This needs to stay here until our minimum supported version of Node.js is >= 16.9.0.
* Node.js >= 16.9.0 supports error causes natively.
*/
if (options != null && typeof options === 'object' && Object.hasOwn(options, 'cause') && !('cause' in this)) {
const {
cause
} = options;
this.cause = cause;
if (cause instanceof Error && 'stack' in cause) {
this.stack = `${this.stack}\nCAUSE: ${cause.stack}`;
}
}
}
}
var _default = exports.default = ApiDOMAggregateError;