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
Uniformize Error Types #226
Comments
I'm not very convinced. The purpose for the different error types is precisely so that you can differentiate them. If we are using them inconsistently then that is worth fixing. But I don't think we are going to make a custom error class for type errors, for example. We use |
@sholladay Thanks for your feedback. Let's say you want to display a custom message "Cannot reach our servers. Are you connected to the Internet?" on your web app when a call fails due to an unreachable URL. In that case, ky throws a TypeError (when the timeout parameter is set to 0), as for ky configuration errors. How do you distinguish between both? should I really inspect error.stack? |
What is the actual error message you are seeing? Do you have a reproducible example? It sounds like you are talking about an error that comes from The way I do a custom message for network errors in my apps is to check It would be nice to have an example of such error handling in our documentation, including the |
I think this problem could be solved via |
This comment has been minimized.
This comment has been minimized.
@GeoMC you didn't show all of your code and I don't know how
Your problem really has nothing to do with this issue thread you commented on here. In the future, please ask support questions on StackOverflow or open a new issue. |
Closing due to lack of activity and specific action items. I agree that error handling for |
While using ky I noticed that errors thrown are not uniformized. Sometimes a custom ky error type is used and sometimes a raw TypeError is thrown.
Let's say you have a web app with a function whose purpose is to display error messages based on error types, then managing the different ky options is just a mess. For instance, when the URL considered is not reachable a TypeError is thrown but a call with failing HTTP calls uses a custom HTTPError. In the former case, when a TypeError is thrown, there no easy means to know in the browser that the error is a ky error: the value is an empty object.
I would suggest using custom error types for all errors with a root one that extends Error.
The text was updated successfully, but these errors were encountered: