diff --git a/app/error/type/client/exists.js b/app/error/type/client/exists.js new file mode 100644 index 0000000..fd3116e --- /dev/null +++ b/app/error/type/client/exists.js @@ -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; diff --git a/app/error/type/client/not-found.js b/app/error/type/client/not-found.js index 0e1541a..0423470 100644 --- a/app/error/type/client/not-found.js +++ b/app/error/type/client/not-found.js @@ -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); } /**