6

No need to declare checked exceptions in throws clause or handling them in try/catch block in scala is the feature that I love. But it can be a problem when exception must be handled but was ignored. I'm looking for tools (maybe compiler flag/plugin) to find methods that ignored checked exceptions.

michael.kebe
  • 10,916
  • 3
  • 44
  • 62
Jeriho
  • 7,129
  • 9
  • 41
  • 57
  • 3
    There was a discussion on the scala debate maillinglist and Martin Odersky said this: http://groups.google.com/group/scala-debate/msg/99369ca6c4959894 – michael.kebe Jun 15 '11 at 09:15

2 Answers2

0

One option is catch the exception at a very high level of you application (The top would be the main-method).

Another option would be to use an UncaughtExceptionHandler (if you are on a JVM):

object MyUncaughtExceptionHandler extends Thread.UncaughtExceptionHandler {
  def uncaughtException(thread: Thread, throwable: Throwable) {
    println("Something bad happened!")
  }
}

val t = new Thread(new Runnable {
  override def run() {
    null.toString
  }
});

t.setUncaughtExceptionHandler(MyUncaughtExceptionHandler)
t.start()
michael.kebe
  • 10,916
  • 3
  • 44
  • 62
0

AFAIK, there is no such tools, however one technique I've used successfully is to simply install an at-throw-point break point in your IDE (IntelliJ or Eclipse) for java.lang.Throwable which will pause execution at throw point of every java exception (or error) as the program runs and then to keep hitting "play" to see them all (at least on the path of execution you're interested in)

Cheers...

Alex Kravets
  • 524
  • 4
  • 12