Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Added exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenedith committed Nov 11, 2015
1 parent 6e33829 commit 797c718
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ module.exports = {

error: {
ServiceUnavailableError: require('./lib/error/serviceUnavailableError').ServiceUnavailableError,
UnauthorizedUserError: require('./lib/error/unauthorizedUserError').UnauthorizedUserError
UnauthorizedUserError: require('./lib/error/unauthorizedUserError').UnauthorizedUserError,
AlreadyExistsError: require('./lib/error/alreadyExistsError').AlreadyExistsError,
UnknownValidateError: require('./lib/error/unknownValidateError').UnknownValidateError,
InvalidPointOfSaleError: require('./lib/error/invalidPointOfSaleError').InvalidPointOfSaleError,
InvalidDateError: require('./lib/error/invalidDateError').InvalidDateError,
InvalidAmountError: require('./lib/error/invalidAmountError').InvalidAmountError,
InvalidTaxRegistrationNumberError: require('./lib/error/invalidTaxRegistrationNumberError').InvalidTaxRegistrationNumberError
},
enum: {
Brand: require('./lib/model/brand').Brand,
Expand Down
12 changes: 12 additions & 0 deletions lib/error/alreadyExistsError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var util = require('util');

var AlreadyExistsError = function AlreadyExistsError(message, userMessage) {
Error.call(this);
this.name = 'AlreadyExistsError';
this.message = message;
this.userMessage = userMessage;
};

util.inherits(AlreadyExistsError, Error);

module.exports.AlreadyExistsError = AlreadyExistsError;
13 changes: 13 additions & 0 deletions lib/error/invalidAmountError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var util = require('util');

var InvalidAmountError = function InvalidAmountError(message, userMessage, field) {
Error.call(this);
this.name = 'InvalidAmountError';
this.message = message;
this.userMessage = userMessage;
this.field = field;
};

util.inherits(InvalidAmountError, Error);

module.exports.InvalidAmountError = InvalidAmountError;
13 changes: 13 additions & 0 deletions lib/error/invalidDateError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var util = require('util');

var InvalidDateError = function InvalidDateError(message, userMessage, field) {
Error.call(this);
this.name = 'InvalidDateError';
this.message = message;
this.userMessage = userMessage;
this.field = field;
};

util.inherits(InvalidDateError, Error);

module.exports.InvalidDateError = InvalidDateError;
13 changes: 13 additions & 0 deletions lib/error/invalidPointOfSaleError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var util = require('util');

var InvalidPointOfSaleError = function InvalidPointOfSaleError(message, userMessage, field) {
Error.call(this);
this.name = 'InvalidPointOfSaleError';
this.message = message;
this.userMessage = userMessage;
this.field = field;
};

util.inherits(InvalidPointOfSaleError, Error);

module.exports.InvalidPointOfSaleError = InvalidPointOfSaleError;
13 changes: 13 additions & 0 deletions lib/error/invalidTaxRegistrationNumberError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var util = require('util');

var InvalidTaxRegistrationNumberError = function InvalidTaxRegistrationNumberError(message, userMessage, field) {
Error.call(this);
this.name = 'InvalidTaxRegistrationNumberError';
this.message = message;
this.userMessage = userMessage;
this.field = field;
};

util.inherits(InvalidTaxRegistrationNumberError, Error);

module.exports.InvalidTaxRegistrationNumberError = InvalidTaxRegistrationNumberError;
12 changes: 12 additions & 0 deletions lib/error/unknownValidateError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var util = require('util');

var UnknownValidateError = function UnknownValidateError(message, userMessage) {
Error.call(this);
this.name = 'UnknownValidateError';
this.message = message;
this.userMessage = userMessage;
};

util.inherits(UnknownValidateError, Error);

module.exports.UnknownValidateError = UnknownValidateError;
42 changes: 42 additions & 0 deletions test/indexTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@ describe('index test', function () {
done();
});

it('should export AlreadyExistsError', function (done) {

var AlreadyExistsError = index.error.AlreadyExistsError;
should.exist(AlreadyExistsError);
done();
});

it('should export UnknownValidateError', function (done) {

var UnknownValidateError = index.error.UnknownValidateError;
should.exist(UnknownValidateError);
done();
});

it('should export InvalidPointOfSaleError', function (done) {

var InvalidPointOfSaleError = index.error.InvalidPointOfSaleError;
should.exist(InvalidPointOfSaleError);
done();
});

it('should export InvalidDateError', function (done) {

var InvalidDateError = index.error.InvalidDateError;
should.exist(InvalidDateError);
done();
});

it('should export InvalidAmountError', function (done) {

var InvalidAmountError = index.error.InvalidAmountError;
should.exist(InvalidAmountError);
done();
});

it('should export InvalidTaxRegistrationNumberError', function (done) {

var InvalidTaxRegistrationNumberError = index.error.InvalidTaxRegistrationNumberError;
should.exist(InvalidTaxRegistrationNumberError);
done();
});

it('should export agreementsRequest', function (done) {

var agreementsRequest = index.model.agreementsRequest;
Expand Down

0 comments on commit 797c718

Please sign in to comment.