Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-custom-error

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-custom-error - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

18

CHANGELOG.md

@@ -0,1 +1,19 @@

<a name="2.2.0"></a>
# [2.2.0](https://github.com/adriengibrat/ts-custom-error/compare/v2.1.0...v2.2.0) (2018-04-04)
### Features
* Add custom error name support ([7791153](https://github.com/adriengibrat/ts-custom-error/commit/7791153))
<a name="2.1.0"></a>
# [2.1.0](https://github.com/adriengibrat/ts-custom-error/compare/v2.0.0...v2.1.0) (2018-03-24)
### Features
* Improve factory typings ([dc1eed6](https://github.com/adriengibrat/ts-custom-error/commit/dc1eed6))
<a name="2.0.0"></a>

@@ -2,0 +20,0 @@ # [2.0.0](https://github.com/adriengibrat/ts-custom-error/compare/v1.0.1...v2.0.0) (2018-03-16)

1

dist/custom-error.d.ts
export declare class CustomError extends Error {
name: string;
constructor(message?: string);
}

@@ -45,2 +45,3 @@ /*! *****************************************************************************

var _this = _super.call(this, message) || this;
_this.name = _newTarget.name;
fixProto(_this, _newTarget.prototype);

@@ -67,2 +68,3 @@ fixStack(_this);

fn.apply(this, args);
this.name = fn.name || parent.name;
fixStack(this, CustomError);

@@ -69,0 +71,0 @@ }

6

dist/custom-error.umd.js

@@ -55,2 +55,3 @@ (function (global, factory) {

var _this = _super.call(this, message) || this;
_this.name = _newTarget.name;
fixProto(_this, _newTarget.prototype);

@@ -66,3 +67,3 @@ fixStack(_this);

//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImN1c3RvbS1lcnJvci50cyhvcmlnaW5hbCkiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsWUFBWSxhQUFhO0FBQ3pCLFFBQVMsVUFBVSxlQUFnQjtB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G1lc3NhZ2UpIHtcclxuICAgICAgICB2YXIgX25ld1RhcmdldCA9IHRoaXMuY29uc3RydWN0b3I7XHJcbiAgICAgICAgdmFyIF90aGlzID0gX3N1cGVyLmNhbGwodGhpcywgbWVzc2FnZSkgfHwgdGhpcztcclxuICAgICAgICBfdGhpcy5uYW1lID0gX25ld1RhcmdldC5uYW1lO1xyXG4gICAgICAgIGZpeFByb3RvKF90aGlzLCBfbmV3VGFyZ2V0LnByb3RvdHlwZSk7XHJcbiAgICAgICAgZml4U3RhY2soX3RoaXMpO1xyXG4gICAgICAgIHJldHVybiBfdGhpcztcclxuICAgIH1cclxuICAgIHJldHVybiBDdXN0b21FcnJvcjtcclxufShFcnJvcikpO1xyXG5leHBvcnQgeyBDdXN0b21FcnJvciB9O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1jdXN0b20tZXJyb3IuanMubWFwIl19

@@ -82,2 +83,3 @@ function customErrorFactory(fn, parent) {

fn.apply(this, args);
this.name = fn.name || parent.name;
fixStack(this, CustomError);

@@ -101,3 +103,3 @@ }

//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZhY3RvcnkudHMob3JpZ2luYWwpIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFFBQVMsZUFBZ0I7QUFDekIsT0FBTyxTQUFTLG1CQUFtQixFQUFJLEVBQUEsUUFBUTtJQUMzQyxJQUFJLE1BQUEsQ0FBQSxHQUFBLENBQVcsSUFBQSxDQUFLLEdBQUc7UUFBRSxNQUFBLENBQUEsQ0FBQSxDQUFTO0lBQXRDO0lBQ0ksU0FBUyxjQUFjO1FBQ25CLEdBQUEsQ0FBSSxPQUFPO1FBQ1gsS0FBSyxHQUFBLENBQUksS0FBSyxFQUFHLEVBQUEsQ0FBQSxDQUFBLENBQUssU0FBQSxDQUFVLFFBQVEsRUFBQSxJQUFNO1lBQzFDLElBQUEsQ0FBSyxHQUFMLENBQUEsQ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2YgQ3VzdG9tRXJyb3IpKVxyXG4gICAgICAgICAgICByZXR1cm4gbmV3IChDdXN0b21FcnJvci5iaW5kLmFwcGx5KEN1c3RvbUVycm9yLCBbdm9pZCAwXS5jb25jYXQoYXJncykpKSgpO1xyXG4gICAgICAgIHBhcmVudC5hcHBseSh0aGlzLCBhcmdzKTtcclxuICAgICAgICBmbi5hcHBseSh0aGlzLCBhcmdzKTtcclxuICAgICAgICBmaXhTdGFjayh0aGlzLCBDdXN0b21FcnJvcik7XHJcbiAgICB9XHJcbiAgICByZXR1cm4gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoQ3VzdG9tRXJyb3IsIHtcclxuICAgICAgICBwcm90b3R5cGU6IHtcclxuICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUocGFyZW50LnByb3RvdHlwZSwge1xyXG4gICAgICAgICAgICAgICAgY29uc3RydWN0b3I6IHtcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogQ3VzdG9tRXJyb3IsXHJcbiAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsXHJcbiAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgfSksXHJcbiAgICAgICAgfSxcclxuICAgIH0pO1xyXG59XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWZhY3RvcnkuanMubWFwIl19
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZhY3RvcnkudHMob3JpZ2luYWwpIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFFBQVMsZUFBZ0I7QUFDekIsT0FBTyxTQUFTLG1CQUFtQixFQUFJLEVBQUEsUUFBUTtJQUMzQyxJQUFJLE1BQUEsQ0FBQSxHQUFBLENBQVcsSUFBQSxDQUFLLEdBQUc7UUFBRSxNQUFBLENBQUEsQ0FBQSx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HBhcmVudCA9PT0gdm9pZCAwKSB7IHBhcmVudCA9IEVycm9yOyB9XHJcbiAgICBmdW5jdGlvbiBDdXN0b21FcnJvcigpIHtcclxuICAgICAgICB2YXIgYXJncyA9IFtdO1xyXG4gICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XHJcbiAgICAgICAgICAgIGFyZ3NbX2ldID0gYXJndW1lbnRzW19pXTtcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKCEodGhpcyBpbnN0YW5jZW9mIEN1c3RvbUVycm9yKSlcclxuICAgICAgICAgICAgcmV0dXJuIG5ldyAoQ3VzdG9tRXJyb3IuYmluZC5hcHBseShDdXN0b21FcnJvciwgW3ZvaWQgMF0uY29uY2F0KGFyZ3MpKSkoKTtcclxuICAgICAgICBwYXJlbnQuYXBwbHkodGhpcywgYXJncyk7XHJcbiAgICAgICAgZm4uYXBwbHkodGhpcywgYXJncyk7XHJcbiAgICAgICAgdGhpcy5uYW1lID0gZm4ubmFtZSB8fCBwYXJlbnQubmFtZTtcclxuICAgICAgICBmaXhTdGFjayh0aGlzLCBDdXN0b21FcnJvcik7XHJcbiAgICB9XHJcbiAgICByZXR1cm4gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoQ3VzdG9tRXJyb3IsIHtcclxuICAgICAgICBwcm90b3R5cGU6IHtcclxuICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUocGFyZW50LnByb3RvdHlwZSwge1xyXG4gICAgICAgICAgICAgICAgY29uc3RydWN0b3I6IHtcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogQ3VzdG9tRXJyb3IsXHJcbiAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsXHJcbiAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgfSksXHJcbiAgICAgICAgfSxcclxuICAgIH0pO1xyXG59XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWZhY3RvcnkuanMubWFwIl19

@@ -104,0 +106,0 @@ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzKG9yaWdpbmFsKSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGdCQUFBO0FBQ2QsY0FBYyxXQUFBO0FBRGQiLCJmaWxlIjoiaW5kZXgudHMob3JpZ2luYWwpIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9jdXN0b20tZXJyb3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2ZhY3RvcnknO1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1pbmRleC5qcy5tYXAiXX0=

@@ -1,1 +0,1 @@

!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o(t.tsCustomError={})}(this,function(t){function o(t,o){function r(){this.constructor=t}c(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}function r(t,o){var r=Object.setPrototypeOf;r?r(t,o):t.__proto__=o}function e(t,o){void 0===o&&(o=t.constructor);var r=Error.captureStackTrace;r&&r(t,o)}function n(t,o){function r(){for(var n=[],c=0;c<arguments.length;c++)n[c]=arguments[c];if(!(this instanceof r))return new(r.bind.apply(r,[void 0].concat(n)));o.apply(this,n),t.apply(this,n),e(this,r)}return void 0===o&&(o=Error),Object.defineProperties(r,{prototype:{value:Object.create(o.prototype,{constructor:{value:r,writable:!0,configurable:!0}})}})}var c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var r in o)o.hasOwnProperty(r)&&(t[r]=o[r])},i=function(t){function n(o){var n=this.constructor,c=t.call(this,o)||this;return r(c,n.prototype),e(c),c}return o(n,t),n}(Error);t.CustomError=i,t.customErrorFactory=n});
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o(t.tsCustomError={})}(this,function(t){function o(t,o){function r(){this.constructor=t}c(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}function r(t,o){var r=Object.setPrototypeOf;r?r(t,o):t.__proto__=o}function e(t,o){void 0===o&&(o=t.constructor);var r=Error.captureStackTrace;r&&r(t,o)}function n(t,o){function r(){for(var n=[],c=0;c<arguments.length;c++)n[c]=arguments[c];if(!(this instanceof r))return new(r.bind.apply(r,[void 0].concat(n)));o.apply(this,n),t.apply(this,n),this.name=t.name||o.name,e(this,r)}return void 0===o&&(o=Error),Object.defineProperties(r,{prototype:{value:Object.create(o.prototype,{constructor:{value:r,writable:!0,configurable:!0}})}})}var c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var r in o)o.hasOwnProperty(r)&&(t[r]=o[r])},i=function(t){function n(o){var n=this.constructor,c=t.call(this,o)||this;return c.name=n.name,r(c,n.prototype),e(c),c}return o(n,t),n}(Error);t.CustomError=i,t.customErrorFactory=n});
{
"name": "ts-custom-error",
"version": "2.1.0",
"version": "2.2.0",
"description": "Extend native Error to create custom errors",

@@ -28,3 +28,3 @@ "repository": "github:adriengibrat/ts-custom-error",

"postbuild": "uglifyjs --compress --mangle --output $npm_package_browser_min -- $npm_package_browser",
"test": "jest --notify",
"test": "jest",
"coverage": "jest --coverage",

@@ -35,2 +35,4 @@ "commit": "lint-staged && git-cz",

"devDependencies": {
"@semantic-release/changelog": "^2.0.1",
"@semantic-release/git": "^4.0.1",
"@types/jest": "^22.2.2",

@@ -41,3 +43,3 @@ "commitizen": "^2.9.6",

"jest-tap-reporter": "^1.9.0",
"lint-staged": "^7.0.0",
"lint-staged": "^7.0.2",
"microbundle": "^0.4.4",

@@ -52,3 +54,3 @@ "prettier": "^1.11.1",

"tslint-config-standard": "^7.0.0",
"typescript": "^2.7.2"
"typescript": "^2.8.1"
},

@@ -92,12 +94,20 @@ "config": {

"release": {
"verifyConditions": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"prepare": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"publish": [
"@semantic-release/npm",
{
"path": "@semantic-release/npm",
"tarballDir": "."
},
{
"path": "@semantic-release/github",
"assets": [
{
"path": "dist",
"label": "Bundled code"
}
]
"assets": "*.tgz"
}

@@ -104,0 +114,0 @@ ]

@@ -87,4 +87,11 @@ # Typescript Custom Error

- Error name is always `Error` (or the name of the underlying native Error when using `customErrorFactory`). You may fix this behaviour if it's an issue with some legacy code:
#### Minification and transpilation mangle custom Error names.
Unexpected results are:
- Minified identifiers in place of custom Error name in Stacktrace
- Wrong error recognition where using errors name (bad practice) instead of `instanceof`
You may fix this behaviour by:
- Using [uglifyjs options](https://github.com/mishoo/UglifyJS2/blob/harmony/README.md) `--mangle 'except=["MyError"]'` (need to specify all custom error names) or `--keep_fnames` / `--keep_classnames` (nothing to specify but your bundle size will be larger)
- Setting explicitly error name:
```ts

@@ -96,6 +103,3 @@ import { CustomError } from 'ts-custom-error'

super()
// Optional - CustomError does not try to set `name`,
// because minification can mangle the name and
// using errors name instead of `instanceof` is a bad idea.
// But you may want to do it explicitly anyway:
// Set name explicitly as minification can mangle class names
this.name = 'MyError'

@@ -109,3 +113,4 @@ }

const MyError = customErrorFactory(function () {
const MyError = customErrorFactory(function MyError () {
// Set name explicitly as minification can remove function expression names
this.name = 'MyError'

@@ -112,0 +117,0 @@ })

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc