Skip to content

Initial implementation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2017
Merged

Initial implementation #1

merged 2 commits into from
Jun 6, 2017

Conversation

ricardogama
Copy link

@ricardogama ricardogama commented Jun 5, 2017

This PR adds the initial implementation of this module with the following errors:

Name Code Default message
BadRequestError 400 Bad Request
ConflictError 410 Conflict
ForbiddenError 403 Forbidden
GoneError 410 Gone
NotFoundError 404 Not Found
UnauthorizedError 401 Unauthorized
ValidationFailedError 400 ValidationFailed

@ricardogama ricardogama requested a review from rplopes June 5, 2017 14:21
@ricardogama ricardogama force-pushed the feature/initial-implementation branch from 543c023 to 08d10e2 Compare June 5, 2017 14:23
UnauthorizedError,
ValidationFailedError
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably get rid of this test if we use the errors exported by the index in the other tests, i.e. changing from:

const ValidationFailedError = require('../../src/errors/validation-failed-error');

to

const { ValidationFailedError } = require('../../src');

it('should add custom properties', () => {
expect(new UnauthorizedError({ foo: 'bar' }).foo).toBe('bar');
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 out of 5 of these tests are common across the default HTTP errors. Is it possible to abstract them somehow, to avoid the duplication and the potential overlooked typos?

For instance, isolating them inside a util method, and in these HTTP error test files calling that util method. Just a suggestion, don't even know if that works with jest.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the test util I created!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@rplopes
Copy link
Contributor

rplopes commented Jun 6, 2017

Add errors for codes 409 and 500 as well?

@ricardogama ricardogama force-pushed the feature/initial-implementation branch from 08d10e2 to 96d711e Compare June 6, 2017 15:09
@ricardogama
Copy link
Author

@rplopes Added 409 and 410 errors, and left 500 out since it does not seem a common use case as we discussed online.

@ricardogama ricardogama force-pushed the feature/initial-implementation branch from 96d711e to 8f588af Compare June 6, 2017 15:13
Copy link
Contributor

@rplopes rplopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and working great. Should be ready to be used in our projects.

@rplopes rplopes merged commit 2891013 into master Jun 6, 2017
@rplopes rplopes deleted the feature/initial-implementation branch June 6, 2017 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants