Skip to content
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

ArgumentError instead TypeError #90

Closed
electerious opened this issue Jun 7, 2018 · 2 comments
Closed

ArgumentError instead TypeError #90

electerious opened this issue Jun 7, 2018 · 2 comments

Comments

@electerious
Copy link

Is there a reason for using a custom error named ArgumentError instead of the build-in TypeError?

: thrown when passing arguments of the wrong type

@sindresorhus
Copy link
Owner

sindresorhus commented Jun 7, 2018

Say you have ow(input, ow.string.startWith('f')) and input is bar. That is not technically a TypeError. Also good to have a unique error for argument validation errors. Then users can separately detect it from unrelated type errors.

@electerious
Copy link
Author

Good point. Thanks for the explanation!

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

No branches or pull requests

2 participants