But I'm still really confused about what I should ...
# arrow
b
But I'm still really confused about what I should do when executeQuery throw an exception
r
What would be the acceptable behavior?
An exception is always encapsulated by IO
b
testclass.query("Test").unsafeRunSync { result -> result.fold({ println("Error") }, { println(it) }) }
I tried that, but it failed inferring the type
r
unsafeRunSync will always throw the exception
b
facepalm I wanted unsafeRunAsync here
thanks
r
you should either call
attempt
before
unsaferunAsync
which will give you a
Either<Throwable, A>
or have your return type in
query
return an
IO<Either<Throwable, A>>
and keep on composing programs before you run it.
If an app has more than one unsafeRun it's always indication of bad composition
b
for now I'm spreading Arrow things slowly… It is a JavaFX app so I'm not ready to move everything into that
👍 1
r
What I ment to say is that instead of attempt + unsafeRun
you can just call handleError or handleErrorWith
wich will return another IO and it's just like map/flatMap but over the Throwable