nbb 2024-07-06

What's the best practice for printing errors in nbb? Was using js/console.log, but that ends up with a lot of cljs metadata

Wait, I can probably find it myself 😅

(binding [*print-fn* *print-err-fn*]
  (println "whatever"))

(.-isError event) (*print-err-fn* (.-error event))
That seems to be identical to the js/console.error output. Should I be using (throw (js/Error. "My Error")) or something else?

I don't understand the question, what is against your expectation?

If I use *print-err-fn* or js/console.error I see an error like this. Curious if I'm throwing an error in an unidiomatic way or printing it in an unidiomatic way as the meta data of that native js error is not readable and would probably be helpful info to print

if you throw a JS error, why is there metadata on the error?

That's a good question. I wonder if that is something promesa is doing? But something is associating .-data onto the js error instance

ok, try ex-message and ex-data to pull out the message and data and then print like you want

Ahh ok I'll try that, but gotta step out for a bit. Thanks again!

I can definitely work with those but also curious what is formatting clojure errors like the image below? Ideally I'd like to reuse that formatting function over re-implementing something like it