Comparing version 6.2.1 to 7.0.0
@@ -0,1 +1,5 @@ | ||
# [7.0.0](https://github.com/nfroidure/yerror/compare/v6.2.1...v7.0.0) (2023-08-11) | ||
## [6.2.1](https://github.com/nfroidure/yerror/compare/v6.2.0...v6.2.1) (2022-12-19) | ||
@@ -2,0 +6,0 @@ |
@@ -1,172 +0,108 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.YError = void 0; | ||
exports.printStackTrace = printStackTrace; | ||
var _os = _interopRequireDefault(require("os")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
import os from 'os'; | ||
/** | ||
* An YError class able to contain some params and | ||
* A YError class able to contain some params and | ||
* print better stack traces | ||
* @extends Error | ||
*/ | ||
let YError = /*#__PURE__*/function (_Error) { | ||
_inherits(YError, _Error); | ||
/** | ||
* Creates a new YError with an error code | ||
* and some params as debug values. | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...any} [params] | ||
* Some additional debugging values | ||
*/ | ||
function YError(wrappedErrors, errorCode, ...params) { | ||
var _this; | ||
_classCallCheck(this, YError); | ||
// Detecting if wrappedErrors are passed | ||
if (!(wrappedErrors instanceof Array)) { | ||
params = ('undefined' === typeof errorCode ? [] : [errorCode]).concat(params); | ||
errorCode = wrappedErrors; | ||
wrappedErrors = []; | ||
} // Call the parent constructor | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(YError).call(this, errorCode)); // Filling error | ||
_this.code = errorCode || 'E_UNEXPECTED'; | ||
_this.params = params; | ||
_this.wrappedErrors = wrappedErrors; | ||
_this.name = _this.toString(); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_assertThisInitialized(_this), _this.constructor); | ||
class YError extends Error { | ||
code; | ||
params; | ||
wrappedErrors; | ||
constructor(wrappedErrors, errorCode, ...params) { | ||
// Detecting if wrappedErrors are passed | ||
if (!(wrappedErrors instanceof Array)) { | ||
params = ('undefined' === typeof errorCode ? [] : [errorCode]).concat(params); | ||
errorCode = wrappedErrors; | ||
wrappedErrors = []; | ||
} | ||
// Call the parent constructor | ||
super(errorCode); | ||
// Filling error | ||
this.code = errorCode || 'E_UNEXPECTED'; | ||
this.params = params; | ||
this.wrappedErrors = wrappedErrors; | ||
this.name = this.toString(); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
} | ||
return _this; | ||
} | ||
_createClass(YError, [{ | ||
key: "toString", | ||
value: function toString() { | ||
return (this.wrappedErrors.length ? // eslint-disable-next-line | ||
this.wrappedErrors[this.wrappedErrors.length - 1].stack + _os.default.EOL : '') + this.constructor.name + ': ' + this.code + ' (' + this.params.join(', ') + ')'; | ||
/** | ||
* Wraps any error and output a YError with an error | ||
* code and some params as debug values. | ||
* @param {Error} err | ||
* The error to wrap | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...YErrorParams} [params] | ||
* Some additional debugging values | ||
* @return {YError} | ||
* The wrapped error | ||
*/ | ||
static wrap(err, errorCode, ...params) { | ||
const wrappedErrorIsACode = _looksLikeAYErrorCode(err.message); | ||
const wrappedErrors = ('wrappedErrors' in err ? err.wrappedErrors : []).concat(err); | ||
if (!errorCode) { | ||
if (wrappedErrorIsACode) { | ||
errorCode = err.message; | ||
} | ||
else { | ||
errorCode = 'E_UNEXPECTED'; | ||
} | ||
} | ||
if (err.message && !wrappedErrorIsACode) { | ||
params.push(err.message); | ||
} | ||
return new YError(wrappedErrors, errorCode, ...params); | ||
} | ||
}]); | ||
return YError; | ||
}(_wrapNativeSuper(Error)); | ||
/** | ||
* Wraps any error and output a YError with an error | ||
* code and some params as debug values. | ||
* @param {Error} err | ||
* The error to wrap | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...any} [params] | ||
* Some additional debugging values | ||
* @return {YError} | ||
* The wrapped error | ||
*/ | ||
exports.YError = YError; | ||
YError.wrap = function yerrorWrap(err, errorCode, ...params) { | ||
let yError = null; | ||
const wrappedErrorIsACode = _looksLikeAYErrorCode(err.message); | ||
const wrappedErrors = (err.wrappedErrors || []).concat(err); | ||
if (!errorCode) { | ||
if (wrappedErrorIsACode) { | ||
errorCode = err.message; | ||
} else { | ||
errorCode = 'E_UNEXPECTED'; | ||
/** | ||
* Return a YError as is or wraps any other error and output | ||
* a YError with a code and some params as debug values. | ||
* @param {Error} err | ||
* The error to cast | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...YErrorParams} [params] | ||
* Some additional debugging values | ||
* @return {YError} | ||
* The wrapped error | ||
*/ | ||
static cast(err, errorCode, ...params) { | ||
if (_looksLikeAYError(err)) { | ||
return err; | ||
} | ||
return YError.wrap(err, errorCode, ...params); | ||
} | ||
} | ||
if (err.message && !wrappedErrorIsACode) { | ||
params.push(err.message); | ||
} | ||
yError = new YError(wrappedErrors, errorCode, ...params); | ||
return yError; | ||
}; | ||
/** | ||
* Same than `YError.wrap()` but preserves the code | ||
* and the debug values of the error if it is | ||
* already an instance of the YError constructor. | ||
* @param {Error} err | ||
* The error to bump | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...YErrorParams} [params] | ||
* Some additional debugging values | ||
* @return {YError} | ||
* The wrapped error | ||
*/ | ||
static bump(err, errorCode, ...params) { | ||
if (_looksLikeAYError(err)) { | ||
return YError.wrap(err, err.code, ...err.params); | ||
} | ||
return YError.wrap(err, errorCode, ...params); | ||
} | ||
toString() { | ||
return ((this.wrappedErrors.length | ||
? // eslint-disable-next-line | ||
this.wrappedErrors[this.wrappedErrors.length - 1].stack + os.EOL | ||
: '') + | ||
this.constructor.name + | ||
': ' + | ||
this.code + | ||
' (' + | ||
this.params.join(', ') + | ||
')'); | ||
} | ||
} | ||
/** | ||
* Return a YError as is or wraps any other error and output | ||
* a YError with a code and some params as debug values. | ||
* @param {Error} err | ||
* The error to cast | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...any} [params] | ||
* Some additional debugging values | ||
* @return {YError} | ||
* The wrapped error | ||
*/ | ||
YError.cast = function yerrorCast(err, ...params) { | ||
if (_looksLikeAYError(err)) { | ||
return err; | ||
} | ||
return YError.wrap.apply(YError, [err].concat(params)); | ||
}; | ||
/** | ||
* Same than `YError.wrap()` but preserves the code | ||
* and the debug values of the error if it is | ||
* already an instance of the YError constructor. | ||
* @param {Error} err | ||
* The error to bump | ||
* @param {string} [errorCode = 'E_UNEXPECTED'] | ||
* The error code corresponding to the actual error | ||
* @param {...any} [params] | ||
* Some additional debugging values | ||
* @return {YError} | ||
* The wrapped error | ||
*/ | ||
YError.bump = function yerrorBump(err, ...params) { | ||
if (_looksLikeAYError(err)) { | ||
return YError.wrap.apply(YError, [err, err.code].concat(err.params)); | ||
} | ||
return YError.wrap.apply(YError, [err].concat(params)); | ||
}; | ||
/** | ||
* Allow to print a stack from anything (especially catched | ||
@@ -179,20 +115,27 @@ * errors that may or may not contain errors 🤷). | ||
*/ | ||
function printStackTrace(err) { | ||
return typeof err === 'object' && typeof err.stack === 'string' ? err.stack : `[no_stack_trace]: error is ${err != null && typeof err.toString === 'function' ? err.toString() : typeof err}`; | ||
} // In order to keep compatibility through major versions | ||
export function printStackTrace(err) { | ||
return typeof err === 'object' && typeof err.stack === 'string' | ||
? err.stack | ||
: `[no_stack_trace]: error is ${err != null && typeof err.toString === 'function' | ||
? err.toString() | ||
: typeof err}`; | ||
} | ||
// In order to keep compatibility through major versions | ||
// we have to make kind of an cross major version instanceof | ||
function _looksLikeAYError(err) { | ||
return err instanceof YError || err.constructor && err.constructor.name && err.constructor.name.endsWith('Error') && 'string' === typeof err.code && _looksLikeAYErrorCode(err.code) && err.params && err.params instanceof Array; | ||
return (!!(err instanceof YError) || | ||
!!(err.constructor && | ||
err.constructor.name && | ||
err.constructor.name.endsWith('Error') && | ||
'code' in err && | ||
'string' === typeof err.code && | ||
_looksLikeAYErrorCode(err.code) && | ||
'params' in err && | ||
err.params && | ||
err.params instanceof Array)); | ||
} | ||
function _looksLikeAYErrorCode(str) { | ||
return /^([A-Z0-9_]+)$/.test(str); | ||
return /^([A-Z0-9_]+)$/.test(str); | ||
} | ||
var _default = YError; | ||
exports.default = _default; | ||
export { YError }; | ||
//# sourceMappingURL=index.js.map |
160
package.json
{ | ||
"name": "yerror", | ||
"version": "6.2.1", | ||
"description": "It helps to know why you got an error.", | ||
"main": "dist/index", | ||
"module": "dist/index.mjs", | ||
"types": "src/index.d.ts", | ||
"browser": "dist/index", | ||
"metapak": { | ||
@@ -14,12 +7,12 @@ "configs": [ | ||
"eslint", | ||
"babel", | ||
"tsesm", | ||
"jest", | ||
"codeclimate", | ||
"mocha", | ||
"travis", | ||
"karma", | ||
"ghactions", | ||
"jsdocs" | ||
], | ||
"data": { | ||
"testsFiles": "src/*.mocha.js", | ||
"files": "src/*.js", | ||
"files": "'src/**/*.ts'", | ||
"testsFiles": "'src/**/*.test.ts'", | ||
"distFiles": "'dist/**/*.js'", | ||
"ignore": [ | ||
@@ -34,26 +27,26 @@ "dist" | ||
}, | ||
"name": "yerror", | ||
"version": "7.0.0", | ||
"description": "It helps to know why you got an error.", | ||
"scripts": { | ||
"build": "rm -rf dist && npm run compile && npm run test:build", | ||
"build": "rimraf 'dist' && tsc --outDir dist", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md", | ||
"cli": "env NODE_ENV=${NODE_ENV:-cli}", | ||
"compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs", | ||
"compile:cjs": "babel --env-name=cjs --out-dir=dist --source-maps=true src", | ||
"compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --source-maps=true src", | ||
"cover": "nyc npm test && nyc report --reporter=html --reporter=text", | ||
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls && rm -rf ./coverage", | ||
"cover": "npm run jest -- --coverage", | ||
"coveralls": "npm run cover && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage", | ||
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz", | ||
"doc": "echo \"# API\" > API.md; jsdoc2md src/*.js >> API.md && git add API.md", | ||
"karma": "karma start karma.conf.js", | ||
"lint": "eslint src/*.js", | ||
"doc": "echo \"# API\" > API.md; jsdoc2md 'dist/**/*.js' >> API.md && git add API.md", | ||
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest", | ||
"lint": "eslint 'src/**/*.ts'", | ||
"metapak": "metapak", | ||
"mocha": "mocha --require '@babel/register' src/*.mocha.js", | ||
"precz": "npm t && npm run lint && npm run metapak -- -s && npm run compile && npm run doc", | ||
"prettier": "prettier --write src/*.js", | ||
"preversion": "npm t && npm run lint && npm run metapak -- -s && npm run compile && npm run doc", | ||
"test": "npm run mocha && npm run karma", | ||
"test:build": "mocha dist/*.mocha.js", | ||
"precz": "npm t && npm run lint && npm run build && npm run metapak -- -s && npm run doc", | ||
"prettier": "prettier --write 'src/**/*.ts'", | ||
"preversion": "npm t && npm run lint && npm run build && npm run metapak -- -s && npm run doc", | ||
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022", | ||
"test": "echo \"WARNING: No tests specified\" && npm run jest", | ||
"type-check": "tsc --pretty --noEmit", | ||
"version": "npm run changelog" | ||
}, | ||
"engines": { | ||
"node": ">=12.19.0" | ||
"node": ">=18.16.0" | ||
}, | ||
@@ -79,30 +72,22 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/cli": "^7.17.10", | ||
"@babel/core": "^7.18.2", | ||
"@babel/eslint-parser": "^7.18.2", | ||
"@babel/plugin-proposal-class-properties": "^7.7.4", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.18.0", | ||
"@babel/plugin-transform-classes": "^7.7.4", | ||
"@babel/preset-env": "^7.18.2", | ||
"@babel/register": "^7.17.7", | ||
"babel-plugin-transform-builtin-extend": "^1.1.2", | ||
"browserify": "^17.0.0", | ||
"commitizen": "^4.2.4", | ||
"conventional-changelog-cli": "^2.2.2", | ||
"@swc/cli": "^0.1.62", | ||
"@swc/core": "^1.3.76", | ||
"@swc/helpers": "^0.5.1", | ||
"@swc/jest": "^0.2.28", | ||
"@typescript-eslint/eslint-plugin": "^6.3.0", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"commitizen": "^4.3.0", | ||
"conventional-changelog-cli": "^3.0.0", | ||
"coveralls": "^3.1.1", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.16.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"jsdoc-to-markdown": "^7.1.0", | ||
"karma": "^6.3.20", | ||
"karma-browserify": "^8.1.0", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-mocha": "^2.0.1", | ||
"karma-sauce-launcher": "^4.3.6", | ||
"metapak": "^4.0.3", | ||
"metapak-nfroidure": "11.2.0", | ||
"mocha": "^10.0.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.6.2" | ||
"eslint": "^8.46.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"jest": "^29.6.2", | ||
"jsdoc-to-markdown": "^8.0.0", | ||
"metapak": "^5.1.3", | ||
"metapak-nfroidure": "15.0.0", | ||
"prettier": "^3.0.1", | ||
"rimraf": "^5.0.1", | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -129,17 +114,15 @@ "dependencies": {}, | ||
"eslint", | ||
"prettier", | ||
"eslint-config-prettier", | ||
"prettier", | ||
"@babel/cli", | ||
"@babel/core", | ||
"@babel/register", | ||
"@babel/preset-env", | ||
"@babel/plugin-proposal-object-rest-spread", | ||
"babel-eslint", | ||
"mocha", | ||
"eslint-plugin-prettier", | ||
"@typescript-eslint/eslint-plugin", | ||
"@typescript-eslint/parser", | ||
"typescript", | ||
"rimraf", | ||
"@swc/cli", | ||
"@swc/core", | ||
"@swc/helpers", | ||
"jest", | ||
"coveralls", | ||
"nyc", | ||
"karma", | ||
"karma-chrome-launcher", | ||
"karma-firefox-launcher", | ||
"karma-mocha", | ||
"@swc/jest", | ||
"jsdoc-to-markdown" | ||
@@ -150,7 +133,10 @@ ] | ||
"extends": [ | ||
"eslint:recommended" | ||
"eslint:recommended", | ||
"plugin:prettier/recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module", | ||
"sourceType": "script", | ||
"modules": true | ||
@@ -169,3 +155,7 @@ }, | ||
"prettier/prettier": "error" | ||
} | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"ignorePatterns": [ | ||
"*.d.ts" | ||
] | ||
}, | ||
@@ -244,3 +234,31 @@ "prettier": { | ||
] | ||
}, | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"jest": { | ||
"coverageReporters": [ | ||
"lcov" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"roots": [ | ||
"<rootDir>/src" | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": [ | ||
"@swc/jest", | ||
{} | ||
] | ||
}, | ||
"testEnvironment": "node", | ||
"moduleNameMapper": { | ||
"(.+)\\.js": "$1" | ||
}, | ||
"extensionsToTreatAsEsm": [ | ||
".ts" | ||
], | ||
"prettierPath": null | ||
} | ||
} |
@@ -10,5 +10,4 @@ [//]: # ( ) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/yerror/blob/master/LICENSE) | ||
[![Build status](https://travis-ci.com/git://github.com/nfroidure/yerror.git.svg?branch=master)](https://travis-ci.com/github/git://github.com/nfroidure/yerror.git) | ||
[![Coverage Status](https://coveralls.io/repos/github/git://github.com/nfroidure/yerror.git/badge.svg?branch=master)](https://coveralls.io/github/git://github.com/nfroidure/yerror.git?branch=master) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/yerror/blob/main/LICENSE) | ||
[![Coverage Status](https://coveralls.io/repos/github/git://github.com/nfroidure/yerror.git/badge.svg?branch=main)](https://coveralls.io/github/git://github.com/nfroidure/yerror.git?branch=main) | ||
@@ -84,3 +83,3 @@ | ||
<dt><a href="#YError">YError</a> ⇐ <code>Error</code></dt> | ||
<dd><p>An YError class able to contain some params and | ||
<dd><p>A YError class able to contain some params and | ||
print better stack traces</p> | ||
@@ -102,3 +101,3 @@ </dd> | ||
## YError ⇐ <code>Error</code> | ||
An YError class able to contain some params and | ||
A YError class able to contain some params and | ||
print better stack traces | ||
@@ -110,3 +109,2 @@ | ||
* [YError](#YError) ⇐ <code>Error</code> | ||
* [new YError([errorCode], [...params])](#new_YError_new) | ||
* [.wrap(err, [errorCode], [...params])](#YError.wrap) ⇒ [<code>YError</code>](#YError) | ||
@@ -116,14 +114,2 @@ * [.cast(err, [errorCode], [...params])](#YError.cast) ⇒ [<code>YError</code>](#YError) | ||
<a name="new_YError_new"></a> | ||
### new YError([errorCode], [...params]) | ||
Creates a new YError with an error code | ||
and some params as debug values. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| [errorCode] | <code>string</code> | <code>"'E_UNEXPECTED'"</code> | The error code corresponding to the actual error | | ||
| [...params] | <code>any</code> | | Some additional debugging values | | ||
<a name="YError.wrap"></a> | ||
@@ -142,3 +128,3 @@ | ||
| [errorCode] | <code>string</code> | <code>"'E_UNEXPECTED'"</code> | The error code corresponding to the actual error | | ||
| [...params] | <code>any</code> | | Some additional debugging values | | ||
| [...params] | <code>YErrorParams</code> | | Some additional debugging values | | ||
@@ -158,3 +144,3 @@ <a name="YError.cast"></a> | ||
| [errorCode] | <code>string</code> | <code>"'E_UNEXPECTED'"</code> | The error code corresponding to the actual error | | ||
| [...params] | <code>any</code> | | Some additional debugging values | | ||
| [...params] | <code>YErrorParams</code> | | Some additional debugging values | | ||
@@ -175,3 +161,3 @@ <a name="YError.bump"></a> | ||
| [errorCode] | <code>string</code> | <code>"'E_UNEXPECTED'"</code> | The error code corresponding to the actual error | | ||
| [...params] | <code>any</code> | | Some additional debugging values | | ||
| [...params] | <code>YErrorParams</code> | | Some additional debugging values | | ||
@@ -196,2 +182,2 @@ <a name="printStackTrace"></a> | ||
# License | ||
[MIT](https://github.com/nfroidure/yerror/blob/master/LICENSE) | ||
[MIT](https://github.com/nfroidure/yerror/blob/main/LICENSE) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20
Yes
53653
12
755
2
175
1