N
N
notxcain2014-10-01 19:19:00
Scala
notxcain, 2014-10-01 19:19:00

How to find out the exception contract for a method in Scala?

I wrote in Objective-C for a long time. All methods that can fail have (one way or another) a reference to an NSError object. Which carries information about the location of the error, its code and payload (such as a message, etc.).
Lately I've been writing in Scala and I have a question about exceptions.
As you know, Future can either complete successfully or with an exception.
Play WS has a method def get(): Future[WSResponse]
The semantics of the WSResponse object is quite clear, it's an HTTP response. But what if there was a network or some other error? That's right - Future will fail as a Throwable.
How can I understand what exceptions to expect in order to correctly apply pattern matching in the recover method? I understand that Scala should avoid exceptions and use the type system as much as possible. But there are still exceptions, and for example, it WS.url("http://null").getwill return java.net.ConnectException.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Smolyakov, 2016-10-16
@spudro

https://developer.android.com/topic/libraries/data...
Here is about using MVVM.
https://habrahabr.ru/company/mobileup/blog/312548/

T
Tiberal, 2016-10-17
@Tiberal

https://github.com/googlesamples/android-architecture

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question