From b366a810f7746d1323734dc1b494828131d0669b Mon Sep 17 00:00:00 2001 From: Sarah Gerweck Date: Tue, 15 Sep 2015 01:32:38 -0700 Subject: [PATCH] ScalaFX App wrapper --- .../org/gerweck/scalafx/util/SFXApp.scala | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/scala/org/gerweck/scalafx/util/SFXApp.scala diff --git a/src/main/scala/org/gerweck/scalafx/util/SFXApp.scala b/src/main/scala/org/gerweck/scalafx/util/SFXApp.scala new file mode 100644 index 0000000..de86150 --- /dev/null +++ b/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 + */ +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 + } + } +}