Skip to content

Having to unwrap exceptions from ExecutionException #111

@maciej

Description

@maciej

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions