-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exceptions in role methods are silently discarded #18
Comments
Those are wrapped into Scala's Either. object SwallowedException extends App {
class CoreType
class ExceptionShowcase extends Compartment {
class Exceptional {
def roleMethod: Unit = {
println("Exceptional::roleMethod()")
throw new Exception("catch me if you can")
}
}
}
new ExceptionShowcase() {
val core = new CoreType()
core play new Exceptional()
(+core).roleMethod() match {
case Left(_) =>
// correct
println("gotcha")
case Right(_) =>
throw new AssertionError("should not be reached")
}
}
} We should add this here. |
This may be a solution for expected, recoverable exceptions (i.e., "checked" in Java), if there is a way to get the exception object (is there a way? glanced over the Scala docs, doesn't seem so). I also understand it's nicely functional, and so on, but: Its definitely not a solution for the exception types that are thrown for unrecoverable programming errors, such as So, currently, the program just will continue to run even if a unrecoverable error in a role occured. But shouldn't it just crash by default (aka, fail early)? |
Yes, you are right. (Also see here) In the current design of the API (all calls to applyDynamic and such), the earliest point to fail would be an explicit match on the resulting Either. |
Throwables in role methods are no longer swallowed. Please review. |
Works as expected 👍 |
Consider the following example (also available at https://github.com/martinmo/SCROLL/tree/scroll-problems):
Expected output:
Actual output:
Another example is the
CheckingsAccount
role in the Banking example, which throws anIllegalArgumentException
that gets also silently swallowed.The text was updated successfully, but these errors were encountered: