A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/onury/custom-error-test below:

onury/custom-error-test: Compare and test various custom error implementations.

Custom Errors in JavaScript

Custom errors are useful when you want to track code with context-specific information. There are several ways to define a custom error in JavaScript. But since inheritance is not a first-citizen feature in JS (until ES2015); there's also so much discussion on how to implement a proper custom error.

See this SO Question, this and this answers, that leads to this discussion (with @mbrowne) and finally, to this module you're viewing.

This module tests various implementations for custom errors, widely used by developers; such as methods making use of Error.call(), Object.create(), new Error(), Object.setPrototypeOf(), extends (ES2015) and util.inherits (Node). See /errors directory for included implementations.

What we expect from a custom error implementation is:

Run npm start which will output test results to console for the current Node.js environment. And will also generate an HTML file, which will display results for the used browser.

Better, you can directly view this page for testing your current browser.

Capture of a test on Chrome 55 browser.

So; with some research, discussions and these tests I think this is the one closest to ES2015's extends Error. If you think this is a bit over-kill, this should be quite enough.

MIT.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4