Skip to content

Commit

Permalink
Add exists client error
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Buczynski committed Jun 15, 2016
1 parent 5da5b05 commit a86517c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions app/error/type/client/exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

/**
* Dependencies
*/
let ClientError = require('../client');

/**
* Constructor
*/
function ExistsError(message, data) {
message = message || 'Already exists';
ClientError.call(this, message, data, 400);
}

/**
* Extend prototype
*/
ExistsError.prototype = Object.create(ClientError.prototype);
ExistsError.prototype.constructor = ExistsError;
ExistsError.prototype.name = 'ExistsError';
ExistsError.prototype.code = 'EXISTS';

//Export
module.exports = ExistsError;
4 changes: 2 additions & 2 deletions app/error/type/client/not-found.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ let ClientError = require('../client');
/**
* Constructor
*/
function NotFoundError(message) {
function NotFoundError(message, data) {
message = message || 'Resource not found';
ClientError.call(this, message, 404);
ClientError.call(this, message, data, 404);
}

/**
Expand Down

0 comments on commit a86517c

Please sign in to comment.