Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for registering an error without providing a name.

  • Loading branch information...
commit 9d1c74eeadf30fc07b2abb155e0ac02d3140896b 1 parent 8651ce9
@vesln vesln authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/errs.js
View
8 lib/errs.js
@@ -134,13 +134,17 @@ exports.handle = function (error, callback) {
//
// ### function register (type, proto)
-// #### @type {string} Type of the error to register.
+// #### @type {string} **Optional** Type of the error to register.
// #### @proto {function} Constructor function of the error to register.
//
// Registers the specified `proto` to `type` for future calls to
// `errors.create(type, opts)`.
//
exports.register = function (type, proto) {
+ if (arguments.length === 1) {
+ proto = type;
+ type = proto.name.toLowerCase();
+ }
exports.registered[type] = proto;
};
@@ -153,4 +157,4 @@ exports.register = function (type, proto) {
//
exports.unregister = function (type) {
delete exports.registered[type];
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.