-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:error-handlingIssues tied with how exceptions are handled, tried, thrown and caught.Issues tied with how exceptions are handled, tried, thrown and caught.itype:enhancement
Description
class A extends Exception
class B extends Exception
def f =
try
throw new Exception()
catch
case e: (A | B) =>
println("matched A or B")
case _ =>
println("not matched")After genBCode:
def f(): Unit =
try throw new Exception() catch
{
case ex1 @ _ =>
matchResult1[Unit]:
{
case val x1: Throwable = ex1
if x1.isInstanceOf[A] || x1.isInstanceOf[B] then
{
case val x2: Exception = x1.asInstanceOf[Exception]
case val e: Exception = x2
{
return[matchResult1] println("matched A or B")
}
}
else ()
{
return[matchResult1] println("not matched")
}
}
}We can generate a multi-exception catch for the simple exception union types like in Java, instead of handling in a new pattern match.
Metadata
Metadata
Assignees
Labels
area:error-handlingIssues tied with how exceptions are handled, tried, thrown and caught.Issues tied with how exceptions are handled, tried, thrown and caught.itype:enhancement