Having to unwrap exceptions from ExecutionException
(It's not strictly a bug, more of an API issue :-) )
Let's take the example code from the homepage and modify it slightly to get a 404 response from housetop.info.
import dispatch._, Defaults._
val svc = url("http://api.hostip.info/country.php-NOT-FOUND")
val country = Http(svc OK as.String)
country.recover { case e => println(e.getClass.getCanonicalName) }
The last line will eventually print java.util.concurrent.ExecutionException. To get to the actual error (StatusCode) I first need to unwrap it.
It would seem intuitive that for a common use case like a non-OK status code returned from the HTTP server the future would fail with StatusCode straight away, which is not the case.
I'm using dispatch 0.11.2.
This seems like a reasonable ask. Given that Dispatch 0.12 and 0.13 have already frozen their APIs, I think the earliest we'd be able to address this is Dispatch 0.14. Before I commit to it though, I want the Development of AHC 2.1 to settle down, since I'm also angling to get that into Dispatch 0.14.
I'm having second thoughts about this change.
The uniformity of knowing that you'll get an ExecutionException has some nice features for error handling, imo.
I'm going to continue considering this, but bump it from the 0.14.0 milestone.