http
http copied to clipboard
Document exceptions thrown
Hi Dartlang 'http' Module Maintainers, Thanks for making this module. I'm using it in a new app. The app needs to know why a request failed so it can display an appropriate message to the user:
- Network problems: dns lookup failure, socket timeout, etc.
- Server error: malformed HTTP response, TLS negotiation failures, gzip error, etc.
How about documenting the various types of exceptions that the http methods can throw? I'm about to start reading the source to find out this information and then write brittle code that depends on undocumented implementation details. I would prefer not to do that. Help me out?
Cheers, Michael
@mleonhard generally, you can expectClientExceptions, plus any errors from the wrapped library in your environment, like io exceptions in flutter, etc. That said, I can't find a list of dart:html errors.
I still need this.
I'm looking for this information as well, the only solution that comes to mind is to read the source or use a catch (Exception), which is a bad practice in my opinion. It should definitely be in the documentation.
The http module is slow to cleanup after timeouts, so I'm now using dart:io:HttpClient. It is also missing documentation on exceptions it throws: https://github.com/dart-lang/sdk/issues/44487