Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
[push] | |
default = current | |
[user] | |
email = [email protected] | |
name = Nik Butenko | |
[core] | |
autocrlf = input | |
excludesfile = /Users/nkbt/.gitignore | |
ignorecase = true | |
[alias] |
{ | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true | |
}, | |
"plugins": ["react"], | |
"ecmaFeatures": { |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.