(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.
(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.
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
StatusCodestraight away, which is not the case.I'm using dispatch 0.11.2.