简体   繁体   中英

handling swing exceptions in scala application

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM