Browse Source

ScalaFX App wrapper

master
Sarah Gerweck 9 years ago
parent
commit
b366a810f7
  1. 37
      src/main/scala/org/gerweck/scalafx/util/SFXApp.scala

37
src/main/scala/org/gerweck/scalafx/util/SFXApp.scala

@ -0,0 +1,37 @@
package org.gerweck.scalafx.util
import scala.util.control.NonFatal
import scalafx.application.JFXApp
import org.log4s.getLogger
/** A ScalaFX application that exposes the parameters and state a bit better
* than how the ScalaFX standard [[scalafx.application.JFXApp]] does it.
*
* @author Sarah Gerweck <sarah@atscale.com>
*/
trait SFXApp extends JFXApp {
/* TBD: Get the ScalaFX team to expose the app args. Their config system is
* not only silly, but they seem to think they should make it impossible
* to use anything else.
*/
protected def args = _args
private[this] var _args: Array[String] = _
override def main(args: Array[String]) = {
try {
_args = args
super.main(args)
} catch {
case NonFatal(e) =>
getLogger.error(e)("Error in main loop")
throw e
case t: Throwable =>
System.err.println("Fatal error in app")
t.printStackTrace
throw t
}
}
}
Loading…
Cancel
Save