Skip to content

Instantly share code, notes, and snippets.

@bjonnh
Created January 1, 2019 23:35
Show Gist options
  • Save bjonnh/eba80a5f7a49b4d0f76444a6bb4f33c0 to your computer and use it in GitHub Desktop.
Save bjonnh/eba80a5f7a49b4d0f76444a6bb4f33c0 to your computer and use it in GitHub Desktop.
Exception works in the controller not the view.
import tornadofx.Controller
import tornadofx.EventBus
import tornadofx.FXEvent
class LogException(val ex: Exception) : FXEvent(EventBus.RunOn.ApplicationThread)
class ExceptionController: Controller() {
init {
subscribe<LogException> {
println("Received an exception "+ it.ex)
}
}
}
class LogView : View() {
lateinit var table: TableView<Exception>
val exceptionsList = mutableListOf<Exception>().observable()
override val root = hbox {
table = tableview(exceptionsList) {
readonlyColumn("cause", Exception::cause)
readonlyColumn("message", Exception::message)
}
}
init {
println("Setting up")
subscribe<LogException> {
println("Caught an exception in the logview "+it.ex)
exceptionsList.add(it.ex)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment