You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
["couldn't load image: /my-image.png"]
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:
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 type field of the error is not particularly important. It does allow for more than one error, but if there is only one then it can be omitted. The value in separating out the url from the human-readable message is the main thing I was tryna communicate ✌️
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: