Comparing version 0.4.4 to 0.5.0
@@ -6,2 +6,23 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
///--- Error Base class | ||
function RESTError(errorName, errorCode, msg, caller) { | ||
if (Error.captureStackTrace) | ||
Error.captureStackTrace(this, caller || RESTError); | ||
this.__defineGetter__('code', function() { | ||
return errorCode; | ||
}); | ||
this.__defineGetter__('name', function() { | ||
return errorName; | ||
}); | ||
this.__defineGetter__('message', function() { | ||
return msg || errorName; | ||
}); | ||
} | ||
util.inherits(RESTError, Error); | ||
module.exports = { | ||
@@ -51,1 +72,21 @@ | ||
}; | ||
Object.keys(RestCodes).forEach(function(code) { | ||
var err = '' + code; | ||
if (!/\w+Error$/.test(err)) | ||
err += 'Error'; | ||
// At this point LDAP_OPERATIONS_ERROR is now OperationsError in $err | ||
// and 'Operations Error' in $msg | ||
module.exports[err] = function(code, message, caller) { | ||
RESTError.call(this, | ||
err, | ||
code, | ||
(typeof(message) === 'string' ? message : ''), | ||
caller || module.exports[err]); | ||
} | ||
module.exports[err].constructor = module.exports[err]; | ||
util.inherits(module.exports[err], RESTError); | ||
}); |
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
var errors = require('./error'); | ||
module.exports = { | ||
@@ -23,4 +25,2 @@ | ||
newError: require('./error').newError, | ||
RestCodes: require('./rest_codes'), | ||
@@ -33,1 +33,6 @@ | ||
}; | ||
Object.keys(errors).forEach(function(k) { | ||
module.exports[k] = errors[k]; | ||
}); |
{ | ||
"name": "restify", | ||
"description": "REST framework specifically meant for web service APIs", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
225542
4295