jscommunity / make-error Goto Github PK
View Code? Open in Web Editor NEWMake your own error types!
License: ISC License
Make your own error types!
License: ISC License
I saw that stack, message, and name were not enumerable while trying to serialize a BaseError using JSON.stringify.
Was this a purposeful decision to match the weird behavior of error?
Hey there, thanks for maintaining this great package!
I'm using the ES6 version with TypeScript (also targetting ES6). Everything works as documented until I subclass a custom error, in which case only the custom error superclass's name comes through, and InstanceOf no longer works as well.
import { BaseError } from 'make-error';
class CustomBaseError extends BaseError {
}
class CustomError extends CustomBaseError {
}
const err = new CustomError();
console.log(err instanceof CustomError); // false
console.log(err instanceof CustomBaseError); // true
console.log(err instanceof BaseError); // true
console.log(err.name); // 'CustomBaseError'
Is this expected behavior/ perhaps just a TypeScript issue?
I've found a decent blog post which describes how to handle it in the Best Practice – Be Specific with Errors
section, though unfortunately the official link to the TS docs is broken.
Not sure if you want to link this, but I wrote https://www.npmjs.com/package/make-error-cause which wraps make-error
with a second argument to specify a cause (useful for nesting errors for better error messaging). I'm using it, for example, Unable to parse "..."\nCaused by: Unexpected token
.
I just unpacked the 1.3.6 tarball, went in, ran jest, and there were four failures:
The first two give Expected: "something" Received: "Error" ; the last two TypeError: Class constructor cannot be invoked without 'new'.
It's a minor issue and it's completely reasonable if you wish to close this, but I run into a TypeError issue when running under 'use strict'
- more information in TypeScript since it's technically an issue there and not here: microsoft/TypeScript#6887. Basically, assignment to this property throw a TypeError under 'use strict'
because it takes shadowing into account even though it's a different object (just a part of the prototype).
Branch | Build failing 🚨 |
---|---|
Dependency | uglify-js |
Current Version | 2.8.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As uglify-js is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 3 commits .
fb2b6c7
v2.8.2
f5cbe19
invert reduce_vars
tracking flag (#1519)
b34fa11
fix evaluate
on object getter & setter (#1515)
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Description of the issue: When invoking the getter of an errors stack
property - this causes the property to be redefined and doesn't explicitly set the writable
property back to true. On certain browsers (tested on iOS Safari - though it works fine on Desktop Chrome) this results in an Attempted to assign to read-only property
unhandled exception to be thrown.
I've put together a little test project to demonstrate the issue, it can be found here.
https://runkit.com/idchlife/5a43b9242cef4c00139318c7
here is example of this error
1.3 is failing this test: https://github.com/blakeembrey/make-error-cause/blob/master/src/index.spec.ts#L19-L20
while 1.2 is working fine.
expected: |-
'SubTestError: more bad\nCaused by: TestError: something bad\nCaused by: Error: boom!'
actual: |-
'TestError: more bad\nCaused by: TestError: something bad\nCaused by: Error: boom!'
at: Test.<anonymous> (/Users/hwong/code/unional/make-error-cause/src/index.spec.ts:20:7)
stack: |-
The current implementation for setting the function name appears to be broken on the latest node version. For reference, see https://travis-ci.org/blakeembrey/make-error-cause/builds/157755665. It's now inheriting constructor
(inferred from the constructor = function () { ... }
line) instead of being set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.