Apply exception handler inlining to a class
Apply exception handler inlining to a class
Is current phase cancelled on this unit?
Is current phase cancelled on this unit?
Finds the first exception handler that matches the current exception
Finds the first exception handler that matches the current exception
Note the following code:
try { throw new IllegalArgumentException("...") } catch { case e: RuntimeException => log("RuntimeException") case i: IllegalArgumentException => log("IllegalArgumentException") }
will print "RuntimeException" => we need the *first* valid handler
There's a hidden catch here: say we have the following code:
try { val exception: Throwable = if (scala.util.Random.nextInt % 2 == 0) new IllegalArgumentException("even") else new StackOverflowError("odd") throw exception } catch { case e: IllegalArgumentException => println("Correct, IllegalArgumentException") case e: StackOverflowError => println("Correct, StackOverflowException") case t: Throwable => println("WROOOONG, not Throwable!") }
We don't want to select a handler if there's at least one that's more specific!
(inlineExceptionHandlersPhase: StringAdd).self
(inlineExceptionHandlersPhase: StringFormat).self
(inlineExceptionHandlersPhase: ArrowAssoc[InlineExceptionHandlersPhase]).x
(Since version 2.10.0) Use leftOfArrow
instead
(inlineExceptionHandlersPhase: Ensuring[InlineExceptionHandlersPhase]).x
(Since version 2.10.0) Use resultOfEnsuring
instead
Inlining Exception Handlers