http icon indicating copy to clipboard operation
http copied to clipboard

Document exceptions thrown

Open mleonhard opened this issue 6 years ago • 4 comments

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 avatar Feb 21 '19 07:02 mleonhard

@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.

micimize avatar Aug 26 '19 15:08 micimize

I still need this.

mleonhard avatar Apr 26 '21 00:04 mleonhard

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.

Krahos avatar May 04 '21 12:05 Krahos

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

mleonhard avatar Aug 18 '21 16:08 mleonhard