-
Notifications
You must be signed in to change notification settings - Fork 258
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
createTexture: improved error message #149
Comments
What errors do you actually expect to catch? The only one twgl actually handles is failure to download image. It doesn't check for any other errors so as it is the callback only has one type of error. |
It makes sense that there's only one error type, which is OK. That's the one that I'm trying to detect: determine when an image fails, and knowing which URL is the culprit so that I can retry the request. The |
First off...thank you for creating twgl! It's been a joy to use. One of the features I'm particularly fond of is how informative
createTexture
(and the related texture APIs are) when it comes to errors. It's incredibly useful how they let you know which images fail to load.I think a small change could make those errors even more useful. Right now, the messages are returned as a string, like:
This is a convenient format for humans to understand, but it's not particularly useful to parse programmatically.
What I'd like to do is catch when there are problems, and re-try the requests. Doing that right now requires parsing the string, which feels a bit brittle.
I'm wondering if it would make sense to return the errors in an object format; perhaps something like this:
This combines the best of both worlds: all of the information a computer needs to know to retry, and a human-readable response.
This would be a breaking change if the messages were just swapped wholesale, so if backwards compatibility is a concern, then perhaps that could be alleviated with a new API. Some ideas are:
or:
What do you think? Thanks for reading!
The text was updated successfully, but these errors were encountered: