Skip to content

Commit

Permalink
rename Error classes to Uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
kbariotis committed Mar 1, 2016
1 parent f4e0ed5 commit ce3cfbb
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions lib/customError.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/badGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function badGateway(message, errorCode) {
module.exports = function BadGateway(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
4 changes: 2 additions & 2 deletions lib/errors/badRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/conflict.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function conflict(message, errorCode) {
module.exports = function Conflict(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/failedDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

module.exports = function failedDependency(message, errorCode) {
module.exports = function FailedDependency(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/forbidden.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function forbidden(message, errorCode) {
module.exports = function Forbidden(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/gatewayTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function gatewayTimeout(message, errorCode) {
module.exports = function GatewayTimeout(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/gone.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function gone(message, errorCode) {
module.exports = function Gone(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/httpVersionNotSupported.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function httpVersionNotSupported(message, errorCode) {
module.exports = function HttpVersionNotSupported(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/internalServerError.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function internalServerError(message, errorCode) {
module.exports = function InternalServerError(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/methodNotAllowed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function methodNotAllowed(message, errorCode) {
module.exports = function MethodNotAllowed(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/networkAuthenticationRequired.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

'use strict';

module.exports = function networkAuthenticationRequired(message, errorCode) {
module.exports = function NetworkAuthenticationRequired(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/notAcceptable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function notAcceptable(message, errorCode) {
module.exports = function NotAcceptable(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/notFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function notFound(message, errorCode) {
module.exports = function NotFound(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/notImplemented.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function notImplemented(message, errorCode) {
module.exports = function NotImplemented(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/paymentRequired.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function paymentRequired(message, errorCode) {
module.exports = function PaymentRequired(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/proxyAuthenticationRequired.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function proxyAuthenticationRequired(message, errorCode) {
module.exports = function ProxyAuthenticationRequired(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/requestTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function requestTimeout(message, errorCode) {
module.exports = function RequestTimeout(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/serviceUnavailable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function serviceUnavailable(message, errorCode) {
module.exports = function ServiceUnavailable(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/unauthorized.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

module.exports = function unauthorized(message, errorCode) {
module.exports = function Unauthorized(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
2 changes: 1 addition & 1 deletion lib/errors/unprocessableEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

'use strict';

module.exports = function unprocessableEntity(message, errorCode) {
module.exports = function UnprocessableEntity(message, errorCode) {

Error.captureStackTrace(this, this.constructor);

Expand Down
10 changes: 5 additions & 5 deletions tests/badGateway.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var assert = require('assert'),
errors = require('../lib');

function doSomethingMoreBad() {
throw new errors.badGateway();
throw new errors.BadGateway();
}

try {
Expand All @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tests/customError.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit ce3cfbb

Please sign in to comment.