-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add and export InvalidHeaderError #17
base: master
Are you sure you want to change the base?
Add and export InvalidHeaderError #17
Conversation
2990601
to
c6aedc2
Compare
@izaakschroeder Any thoughts? |
Thinking of maybe using https://www.npmjs.com/package/es6-error |
Thanks for the contribution so far 😄 Will look at this in more detail tonight after I get some rest. |
bd61193
to
c6aedc2
Compare
@izaakschroeder If you're ok to add it as dependency that's awesome, just let me know. BTW, any reason for babel-core being a dependency? Seems duplicated. |
@izaakschroeder ping |
Sorry for the delay, super busy as of late. Feel free to add the dependency 😄 And |
c6aedc2
to
81ad6cc
Compare
81ad6cc
to
ab4b8ef
Compare
@izaakschroeder Refactored in favour of es6-error and removed babel-core as dependency, please review. |
@izaakschroeder ping |
1 similar comment
@izaakschroeder ping |
@izaakschroeder ping? |
This PR adds the
InvalidHeaderError
which inherits fromTypeError
. Throwing a custom error and exporting it allows a more precise error handling, since it's possible to know that the error was thrown byparse
. For example:So I replaced all
TypeError
throws byInvalidHeaderError
on theparse
module and modified its tests accordingly, adding an assert for its message.The
InvalidHeaderError
implementation was based on the Custom Error Types section of the MDN Error documentation.