handling swing exceptions in scala application

191 Views Asked by At

I'd like to use swing for a scala GUI. The application state is handled by akka actors and may be restored with its fault tolerance.

I'd like to restore application after a swing fault. I've found several recipes for java programmers for establishing EDT exceptions handler as well as creating EDT proxy. What is the scala way for handling swing exceptions? Does scala wrapper provide better tools?

1

There are 1 best solutions below

0
On

Scala permits a Java-like style of coding in most circumstances. More specifically, a try/catch block can be used in scala. However, the syntax is slightly different for the catch block.

catch {
  case e: ExceptionTypeOne => //fill in
  case e: ExceptionTypeTwo => //fill in
  case e: ExceptionTypeThree => //fill in
}

As you can see, the catch catches all exceptions, then sets up a Scala style switch.

I'm not quite a Scala expert or anything, I owe the exact syntax of my answer to this site