@c8/errors
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -119,3 +119,3 @@ 'use strict' | ||
} | ||
})() || Boom.wrap(err) // defaults to HTTP 500 status | ||
})() || (err.name = 'AuthenticationError') ? Boom.unauthorized(err) : Boom.wrap(err) // defaults to HTTP 500 status | ||
@@ -122,0 +122,0 @@ // Make err.data publicly available so we can send extra intel like custom error codes. |
{ | ||
"name": "@c8/errors", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Common errors and their utils used by C8 management", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,2 +19,13 @@ /* eslint-env mocha */ | ||
// Passport JWT Error | ||
function AuthenticationError(message, status) { | ||
Error.call(this); | ||
// Error.captureStackTrace(this, arguments.callee); | ||
this.name = 'AuthenticationError'; | ||
this.message = message; | ||
this.status = status || 401; | ||
} | ||
AuthenticationError.prototype.__proto__ = Error.prototype; | ||
// ---------------------------- | ||
const testParams = { | ||
@@ -33,3 +44,3 @@ param1: 'test1', | ||
forbidden: ['ForbiddenErr'], | ||
unauthorized: ['Unauthorized1', 'Unauthorized2'] | ||
unauthorized: ['Unauthorized1', 'Unauthorized2', 'AuthenticationError'] | ||
} | ||
@@ -169,2 +180,14 @@ | ||
}) | ||
describe('Passport JWT Auth error handling', () => { | ||
let err | ||
before(() => { | ||
err = Errors.utils.toBoom(new AuthenticationError(401), MyCustomErrors, customMapping) | ||
}) | ||
it('should return 401', () => { | ||
err.should.have.a.deep.property('output.statusCode', 401) | ||
}) | ||
}) | ||
}) |
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
15341
333
2