Fork me on GitHub
Pepijn de Vos11:07:26

When you get an error like Uncaught Error: Assert failed: Invalid Hiccup form: [nil #{} {:x 9.004647827148437, :y 3.113865280151367}] (in nyancad.mosaic.frontend.schematic_canvas) how do you trace that back to the code that generated that element? The stacktrace is just a bunch of reagents stuff.

Pepijn de Vos11:07:55

It just gives the top-level function so it could be anywhere...


There are only a very few cases where you should get that error, i.e. if the first element is not a keyword or a function. Here it’s the component itself which is nil (the first element of the vector) which indicates that there’s probably a typo. Do you get a compiler warning about the use of an undeclared var in that namespace? If there’s something more elaborate going on, like dynamically passing the component, it’s probably good practice to include an assert that it’s not nil so you get a more useful error

Pepijn de Vos13:07:21

Yea I'm doing some dynamic stuff...


Then it’s a bit of a detective game 😅 I’d definitely include something in those dynamic components which throws before it returns invalid Hiccup forms

Pepijn de Vos14:07:18

Ok yea adding asserts helps catch the error where it happens.