nodeunit icon indicating copy to clipboard operation
nodeunit copied to clipboard

Allow importing custom error types

Open ludydoo opened this issue 11 years ago • 1 comments

Hi,

I am using node unit and I defined custom error types in this fashion :

var errors = {}
errors.UnknownAttributeError = function(message) {
    this.name = "UnknownAttributeError";
    this.message = message || "UnknownAttributeError";
}
errors.UnknownAttributeError.prototype = new Error();
errors.UnknownAttributeError.prototype.constructor = errors.UnknownAttributeError;

module.exports = errors;

when I import the errors file as so :

var Errors = require('./../../lib/relational/errors');

The new Error() is caught and raised, but I think it should not be...

ludydoo avatar Jan 30 '14 05:01 ludydoo

Yeah, that doesn't sound right. Nodeunit doesn't do anything special looking for new Error() calls... if you can send a pull request with a failing test case I'll take a look.

caolan avatar Feb 01 '14 17:02 caolan