All Projects → onury → custom-error-test

onury / custom-error-test

Licence: MIT license
Compare and test various custom error implementations.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to custom-error-test

My Android Garage
A quick reference guide for Android development.
Stars: ✭ 66 (+106.25%)
Mutual labels:  inheritance
Heir
Helper functions for prototypical inheritance in JavaScript
Stars: ✭ 61 (+90.63%)
Mutual labels:  inheritance
Clean Code Javascript
🛁 Clean Code concepts adapted for JavaScript
Stars: ✭ 62,912 (+196500%)
Mutual labels:  inheritance
Java-Programs
Java Practiced Problems including concepts of OOPS, Interface, String , Collection.
Stars: ✭ 51 (+59.38%)
Mutual labels:  inheritance
JavaCertification
This is a full resource guide for my attempt to get Java 11 Certified
Stars: ✭ 67 (+109.38%)
Mutual labels:  inheritance
django-improved-permissions
Django application made to make django's default permission system more robust.
Stars: ✭ 14 (-56.25%)
Mutual labels:  inheritance
clean-code-javascript-ko
🛁 Clean Code concepts adapted for JavaScript - 한글 번역판 🇰🇷
Stars: ✭ 1,767 (+5421.88%)
Mutual labels:  inheritance
yii2-activerecord-inheritance
ActiveRecord Inheritance is an util to provide the Class Table Inheritance Pattern the to the Yii2 framework
Stars: ✭ 18 (-43.75%)
Mutual labels:  inheritance
java-springboot
(Java & React) Yazılım Geliştirici Yetiştirme Kampı Java kısmına ait yazılan kaynak kodlar ve ödev çalışmalarım.
Stars: ✭ 17 (-46.87%)
Mutual labels:  inheritance
Clean Code Dotnet
🛁 Clean Code concepts and tools adapted for .NET
Stars: ✭ 4,425 (+13728.13%)
Mutual labels:  inheritance
emitty
A platform for finding dependencies between files and building tools for incremental compilation or build.
Stars: ✭ 69 (+115.63%)
Mutual labels:  inheritance
java-notes
Complete Java Note for colleges in Nepal.
Stars: ✭ 30 (-6.25%)
Mutual labels:  inheritance
OOP-In-CPlusPlus
An Awesome Repository On Object Oriented Programming In C++ Language. Ideal For Computer Science Undergraduates, This Repository Holds All The Resources Created And Used By Me - Code & Theory For One To Master Object Oriented Programming. Filled With Theory Slides, Number Of Programs, Concept-Clearing Projects And Beautifully Explained, Well Doc…
Stars: ✭ 27 (-15.62%)
Mutual labels:  inheritance
kaop
Advanced OOP Library with createClass, inheritance, providers, injectors, advices which enables handy Inversion of Control techniques
Stars: ✭ 40 (+25%)
Mutual labels:  inheritance
arm-hard-fault-handler
What to do when Hard fault hits? Debugger and error reporter solution for ARM Cortex M3 and M4.
Stars: ✭ 32 (+0%)
Mutual labels:  error
django-apptemplates
Django template loader that allows you to load and override a template from a specific Django application.
Stars: ✭ 43 (+34.38%)
Mutual labels:  inheritance
tidymodules
An Object-Oriented approach to Shiny modules
Stars: ✭ 110 (+243.75%)
Mutual labels:  inheritance
react-native-easy-state-view
Fully customizable State View for React Native.
Stars: ✭ 21 (-34.37%)
Mutual labels:  error
error-handler
PSR-15 middleware to handle http errors
Stars: ✭ 13 (-59.37%)
Mutual labels:  error
Revisited
🧑‍🤝‍🧑 The visitor pattern revisited. An inheritance-aware acyclic visitor template, any and any-function templates.
Stars: ✭ 14 (-56.25%)
Mutual labels:  inheritance

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:

  • e.constructor.name MUST be set to custom error name.
  • E.prototype MUST inherit from Error.prototype.
  • e.message MUST be set.
  • e MUST be an instance of Error.
  • e MUST be an instance of CustomError.
  • e.stack MUST be set and should have line-tracable info.
  • e.tostring() MUST return error name and/or message.
  • ({}).toString.call(e) SHOULD output "error".
  • and some more...

Test

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.

Screenshot Capture of a test on Chrome 55 browser.

CustomError: The One

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.

License

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].