简体   繁体   English

处理scala应用程序中的swing异常

[英]handling swing exceptions in scala application

I'd like to use swing for a scala GUI. 我想使用swing作为scala GUI。 The application state is handled by akka actors and may be restored with its fault tolerance. 应用程序状态由akka actor处理,可以通过其容错来恢复。

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. 我已经为java程序员找到了几个用于建立EDT异常处理程序以及创建EDT代理的方法。 What is the scala way for handling swing exceptions? 处理swing异常的scala方法是什么? Does scala wrapper provide better tools? scala包装器能提供更好的工具吗?

Scala permits a Java-like style of coding in most circumstances. 在大多数情况下,Scala允许类似Java的编码风格。 More specifically, a try/catch block can be used in scala. 更具体地说,可以在scala中使用try / catch块。 However, the syntax is slightly different for the catch block. 但是,catch块的语法略有不同。

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. 如您所见, catch捕获所有异常,然后设置Scala样式开关。

I'm not quite a Scala expert or anything, I owe the exact syntax of my answer to this site 我不是Scala专家或其他什么,我欠我对这个网站的答案的确切语法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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