I heard from some people that in Scala we tend (like other functional languages) not to interrupt the control flow ... Instead, we return an error in Either Left .
But how do we get stracktrace from this exception? At the moment, I am returning to the left a simple Error class with code, message and reason ( Error too). But if I have an error, I cannot get stacktrace. If my application gets complicated, it can be difficult to find the code block that returned this Error value ... The main reason is important.
So what do we do in practice?
Should I return a java Exception or Throwable in my Left instead of a custom Error ? What is the best practice for handling Scala exceptions without losing important information like stacktrace and reason?
java scala exception exception-handling either
Sebastien Lorber Sep 16 '12 at 19:22 2012-09-16 19:22
source share