diff --git a/lib/customError.js b/lib/customError.js index 48b9bc3..d6daf7c 100644 --- a/lib/customError.js +++ b/lib/customError.js @@ -5,11 +5,11 @@ 'use strict'; -module.exports = function customError(name, message, statusCode, errorCode) { +module.exports = function CustomError(name, message, statusCode, errorCode) { Error.captureStackTrace(this, this.constructor); - this.name = name || 'customError'; + this.name = name || 'CustomError'; this.message = message || 'Custom Error without message'; this.statusCode = statusCode || 400; this.errorCode = errorCode || 400; diff --git a/lib/errors/badGateway.js b/lib/errors/badGateway.js index 8ad8f02..4030f65 100644 --- a/lib/errors/badGateway.js +++ b/lib/errors/badGateway.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function badGateway(message, errorCode) { +module.exports = function BadGateway(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/badRequest.js b/lib/errors/badRequest.js index 68567de..e86ae8d 100644 --- a/lib/errors/badRequest.js +++ b/lib/errors/badRequest.js @@ -4,11 +4,11 @@ 'use strict'; -module.exports = function badRequest(message, errorCode) { +module.exports = function BadRequest(message, errorCode) { Error.captureStackTrace(this, this.constructor); - this.name = 'badRequest'; + this.name = 'BadRequest'; this.message = message || 'Bad Request'; this.statusCode = 400; this.errorCode = errorCode || 400; diff --git a/lib/errors/conflict.js b/lib/errors/conflict.js index 053f8a6..d396135 100644 --- a/lib/errors/conflict.js +++ b/lib/errors/conflict.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function conflict(message, errorCode) { +module.exports = function Conflict(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/failedDependency.js b/lib/errors/failedDependency.js index 20fea0b..5e6fbe1 100644 --- a/lib/errors/failedDependency.js +++ b/lib/errors/failedDependency.js @@ -7,7 +7,7 @@ 'use strict'; -module.exports = function failedDependency(message, errorCode) { +module.exports = function FailedDependency(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/forbidden.js b/lib/errors/forbidden.js index 8ba98e1..9739cb7 100644 --- a/lib/errors/forbidden.js +++ b/lib/errors/forbidden.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function forbidden(message, errorCode) { +module.exports = function Forbidden(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/gatewayTimeout.js b/lib/errors/gatewayTimeout.js index b72edf2..bf3d59e 100644 --- a/lib/errors/gatewayTimeout.js +++ b/lib/errors/gatewayTimeout.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function gatewayTimeout(message, errorCode) { +module.exports = function GatewayTimeout(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/gone.js b/lib/errors/gone.js index 645b2a2..1549742 100644 --- a/lib/errors/gone.js +++ b/lib/errors/gone.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function gone(message, errorCode) { +module.exports = function Gone(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/httpVersionNotSupported.js b/lib/errors/httpVersionNotSupported.js index abd631d..88cef7e 100644 --- a/lib/errors/httpVersionNotSupported.js +++ b/lib/errors/httpVersionNotSupported.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function httpVersionNotSupported(message, errorCode) { +module.exports = function HttpVersionNotSupported(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/internalServerError.js b/lib/errors/internalServerError.js index e51906a..419f2e9 100644 --- a/lib/errors/internalServerError.js +++ b/lib/errors/internalServerError.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function internalServerError(message, errorCode) { +module.exports = function InternalServerError(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/methodNotAllowed.js b/lib/errors/methodNotAllowed.js index 5946c76..c989136 100644 --- a/lib/errors/methodNotAllowed.js +++ b/lib/errors/methodNotAllowed.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function methodNotAllowed(message, errorCode) { +module.exports = function MethodNotAllowed(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/networkAuthenticationRequired.js b/lib/errors/networkAuthenticationRequired.js index 2f7c004..d51c793 100644 --- a/lib/errors/networkAuthenticationRequired.js +++ b/lib/errors/networkAuthenticationRequired.js @@ -6,7 +6,7 @@ 'use strict'; -module.exports = function networkAuthenticationRequired(message, errorCode) { +module.exports = function NetworkAuthenticationRequired(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/notAcceptable.js b/lib/errors/notAcceptable.js index a0d5aa1..c2bbdfa 100644 --- a/lib/errors/notAcceptable.js +++ b/lib/errors/notAcceptable.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function notAcceptable(message, errorCode) { +module.exports = function NotAcceptable(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/notFound.js b/lib/errors/notFound.js index cda6b74..450b668 100644 --- a/lib/errors/notFound.js +++ b/lib/errors/notFound.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function notFound(message, errorCode) { +module.exports = function NotFound(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/notImplemented.js b/lib/errors/notImplemented.js index ddb0a0a..89b893b 100644 --- a/lib/errors/notImplemented.js +++ b/lib/errors/notImplemented.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function notImplemented(message, errorCode) { +module.exports = function NotImplemented(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/paymentRequired.js b/lib/errors/paymentRequired.js index 655b7cb..629c8ad 100644 --- a/lib/errors/paymentRequired.js +++ b/lib/errors/paymentRequired.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function paymentRequired(message, errorCode) { +module.exports = function PaymentRequired(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/proxyAuthenticationRequired.js b/lib/errors/proxyAuthenticationRequired.js index 2219cbc..6f49a1f 100644 --- a/lib/errors/proxyAuthenticationRequired.js +++ b/lib/errors/proxyAuthenticationRequired.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function proxyAuthenticationRequired(message, errorCode) { +module.exports = function ProxyAuthenticationRequired(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/requestTimeout.js b/lib/errors/requestTimeout.js index 082dc48..c8dc390 100644 --- a/lib/errors/requestTimeout.js +++ b/lib/errors/requestTimeout.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function requestTimeout(message, errorCode) { +module.exports = function RequestTimeout(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/serviceUnavailable.js b/lib/errors/serviceUnavailable.js index 032d4e1..2f92580 100644 --- a/lib/errors/serviceUnavailable.js +++ b/lib/errors/serviceUnavailable.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function serviceUnavailable(message, errorCode) { +module.exports = function ServiceUnavailable(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/unauthorized.js b/lib/errors/unauthorized.js index 1a041f0..b5f6a23 100644 --- a/lib/errors/unauthorized.js +++ b/lib/errors/unauthorized.js @@ -4,7 +4,7 @@ 'use strict'; -module.exports = function unauthorized(message, errorCode) { +module.exports = function Unauthorized(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/lib/errors/unprocessableEntity.js b/lib/errors/unprocessableEntity.js index 3e59204..dfc728d 100644 --- a/lib/errors/unprocessableEntity.js +++ b/lib/errors/unprocessableEntity.js @@ -6,7 +6,7 @@ 'use strict'; -module.exports = function unprocessableEntity(message, errorCode) { +module.exports = function UnprocessableEntity(message, errorCode) { Error.captureStackTrace(this, this.constructor); diff --git a/tests/badGateway.spec.js b/tests/badGateway.spec.js index 9cfe593..d3e92b3 100644 --- a/tests/badGateway.spec.js +++ b/tests/badGateway.spec.js @@ -6,7 +6,7 @@ var assert = require('assert'), errors = require('../lib'); function doSomethingMoreBad() { - throw new errors.badGateway(); + throw new errors.BadGateway(); } try { @@ -16,10 +16,10 @@ try { } catch (err) { // The name property should be set to the error's name - assert(err.name = 'badGateway'); + assert(err.name = 'BadGateway'); // The error should be an instance of its class - assert(err instanceof errors.badGateway); + assert(err instanceof errors.BadGateway); // The error should be an instance of builtin Error assert(err instanceof Error); @@ -32,11 +32,11 @@ try { // toString should return the default error message formatting assert.strictEqual(err.toString(), - 'badGateway: Bad Gateway'); + 'BadGateway: Bad Gateway'); // The stack should start with the default error message formatting assert.strictEqual(err.stack.split('\n')[0], - 'badGateway: Bad Gateway'); + 'BadGateway: Bad Gateway'); // The first stack frame should be the function where the error was thrown. assert.strictEqual(err.stack.split('\n')[1].indexOf('doSomethingMoreBad'), 7); diff --git a/tests/customError.spec.js b/tests/customError.spec.js index 8d4d6cb..245347d 100644 --- a/tests/customError.spec.js +++ b/tests/customError.spec.js @@ -6,7 +6,7 @@ var assert = require('assert'), errors = require('../lib'); function doSomethingBad() { - throw new errors.customError('customError', 'It went bad!', 400, 4000); + throw new errors.CustomError('customError', 'It went bad!', 400, 4000); } try { @@ -16,10 +16,10 @@ try { } catch (err) { // The name property should be set to the error's name - assert(err.name = 'customError'); + assert(err.name = 'CustomError'); // The error should be an instance of its class - assert(err instanceof errors.customError); + assert(err instanceof errors.CustomError); // The error should be an instance of builtin Error assert(err instanceof Error); @@ -32,11 +32,11 @@ try { // toString should return the default error message formatting assert.strictEqual(err.toString(), - 'customError: It went bad!'); + 'CustomError: It went bad!'); // The stack should start with the default error message formatting assert.strictEqual(err.stack.split('\n')[0], - 'customError: It went bad!'); + 'CustomError: It went bad!'); // The first stack frame should be the function where the error was thrown. assert.strictEqual(err.stack.split('\n')[1].indexOf('doSomethingBad'), 7);