Comparing version 2.8.4 to 2.8.5
@@ -5,2 +5,7 @@ # restify Changelog | ||
## 2.8.5 | ||
- Add ability to listen for error events | ||
- Documentation fixes | ||
## 2.8.4 | ||
@@ -7,0 +12,0 @@ |
@@ -145,2 +145,4 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved. | ||
} | ||
req.log.trace({name: name, err: err}, 'entering emitRouteError'); | ||
if (server.listeners(name).length > 0) { | ||
@@ -651,2 +653,6 @@ server.emit(name, req, res, once(function () { | ||
var t; | ||
var errName; | ||
var emittedError = false; | ||
if (cb) | ||
cb = once(cb); | ||
@@ -657,5 +663,14 @@ function next(arg) { | ||
if (arg instanceof Error) { | ||
log.trace({err: arg}, 'next(err=%s)', | ||
errName = arg.name.replace(/Error$/, ''); | ||
log.trace({err: arg, errName: errName}, 'next(err=%s)', | ||
(arg.name || 'Error')); | ||
res.send(arg); | ||
if (self.listeners(errName).length > 0) { | ||
self.emit(errName, req, res, arg, once(function () { | ||
res.send(arg); | ||
return (cb ? cb(arg) : true); | ||
})); | ||
emittedError = true; | ||
} else { | ||
res.send(arg); | ||
} | ||
done = true; | ||
@@ -752,3 +767,9 @@ } else if (typeof (arg) === 'string') { | ||
return (cb ? cb(arg) : true); | ||
// don't return cb here if we emit an error since we will cb after the | ||
// handler fires. | ||
if (!emittedError) { | ||
return (cb ? cb(arg) : true); | ||
} else { | ||
return (true); | ||
} | ||
} | ||
@@ -755,0 +776,0 @@ |
@@ -33,3 +33,4 @@ { | ||
"Ben Doerr", | ||
"Patrick Mooney" | ||
"Patrick Mooney", | ||
"Yunong Xiao" | ||
], | ||
@@ -39,3 +40,3 @@ "name": "restify", | ||
"description": "REST framework", | ||
"version": "2.8.4", | ||
"version": "2.8.5", | ||
"repository": { | ||
@@ -42,0 +43,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
180875
4662
8