Skip to content

Commit

Permalink
If coerced error provides a status code, use that
Browse files Browse the repository at this point in the history
  • Loading branch information
billinghamj committed Aug 26, 2015
1 parent 9e92f0d commit cc9bc45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,17 @@ module.exports.coerceError = function (error) {
if (error instanceof CuvvaError)
return error;

var newError;

if (error instanceof Error)
return new CuvvaError('unknown', { message: error.message });
newError = new CuvvaError('unknown', { message: error.message });
else
newError = new CuvvaError('unknown', { error: error });

if (error.statusCode)
newError.httpStatus = error.statusCode;

return new CuvvaError('unknown', { error: error });
return newError;
};

function logger(level) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cuvva-log",
"version": "0.5.1",
"version": "0.5.2",
"description": "Super simple standardized logging used by all Cuvva systems",
"homepage": "https://github.com/cuvva/cuvva-log-node",
"bugs": "https://github.com/cuvva/cuvva-log-node/issues",
Expand Down

0 comments on commit cc9bc45

Please sign in to comment.