fn-fx / fn-fx

A Functional API around JavaFX / OpenJFX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nil cause for error

DonyorM opened this issue · comments

Been getting some errors when compiling my code with a singularly unhelpful stacktrace:

#error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [fn_fx.render_core$get_getter invokeStatic render_core.clj 320]}]
 :trace
 [[fn_fx.render_core$get_getter invokeStatic render_core.clj 320]
  [fn_fx.render_core$get_getter invoke render_core.clj 313]
  [fn_fx.render_core$get_property invokeStatic render_core.clj 104]
  [fn_fx.render_core$get_property invoke render_core.clj 103]
  [fn_fx.fx_dom.FXDom$fn__18478 invoke fx_dom.clj 32]
  [clojure.lang.AFn run AFn.java 22]
  [com.sun.javafx.application.PlatformImpl lambda$null$173 PlatformImpl.java 295]
  [java.security.AccessController doPrivileged AccessController.java -2]
  [com.sun.javafx.application.PlatformImpl lambda$runLater$174 PlatformImpl.java 294]
  [com.sun.glass.ui.InvokeLaterDispatcher$Future run InvokeLaterDispatcher.java 95]
  [com.sun.glass.ui.gtk.GtkApplication _runLoop GtkApplication.java -2]
  [com.sun.glass.ui.gtk.GtkApplication lambda$null$49 GtkApplication.java 139]
  [java.lang.Thread run Thread.java 745
]]}

The errors are most likely my fault, but a better error message (so I could find out what my mistake was), would be great.

Can you provide some code which leads to this error? Maybe it's a bug...

As for better error messages I agree, but this needs to be broken down into something more specific. I think we could start by looking at some use cases where a better error is clearly needed and see how it can be done.
For example one thing that crosses my mind is a validation of the properties, but this is good enough in my opinion. Here's what you get when you try to access a wrong property:

(ui/v-box :listen/height2 {:event :height-change})

leads to

#error {
 :cause javafx.scene.layout.VBox.height2Property()
 :via
 [{:type java.lang.NoSuchMethodException
   :message javafx.scene.layout.VBox.height2Property()
   :at [java.lang.Class getMethod Class.java 1786]}]
 :trace
 [[java.lang.Class getMethod Class.java 1786]
  [fn_fx.render_core$get_prop_methods invokeStatic render_core.clj 313]
  [fn_fx.render_core$get_prop_methods invoke render_core.clj 295]
  [fn_fx.render_core$get_add_listener invokeStatic render_core.clj 331]
  [fn_fx.render_core$get_add_listener invoke render_core.clj 327]
  [fn_fx.render_core$eval2225$fn__2226 invoke render_core.clj 96]
  [clojure.lang.MultiFn invoke MultiFn.java 238]
  [fn_fx.fx_dom.FXDom$fn__2474 invoke fx_dom.clj 24]
  [clojure.lang.AFn run AFn.java 22]
  [com.sun.javafx.application.PlatformImpl lambda$null$173 PlatformImpl.java 295]
  [java.security.AccessController doPrivileged AccessController.java -2]
  [com.sun.javafx.application.PlatformImpl lambda$runLater$174 PlatformImpl.java 294]
  [com.sun.glass.ui.InvokeLaterDispatcher$Future run$$$capture InvokeLaterDispatcher.java 95]
  [com.sun.glass.ui.InvokeLaterDispatcher$Future run InvokeLaterDispatcher.java -1]
  [com.sun.glass.ui.win.WinApplication _runLoop WinApplication.java -2]
  [com.sun.glass.ui.win.WinApplication lambda$null$148 WinApplication.java 191]
  [java.lang.Thread run Thread.java 748]]}

So the question is what other use cases are there which need a better error.