nbb

2024-07-06T21:09:51.480359Z

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

2024-08-01T13:59:45.592419Z

Wait, I can probably find it myself 😅

borkdude 2024-07-06T21:11:17.669719Z

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

2024-07-06T21:14:26.321019Z

Ahhh thanks!

2024-07-06T21:29:31.453749Z

(.-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?

borkdude 2024-07-06T21:32:44.661289Z

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

2024-07-06T21:34:41.622989Z

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

borkdude 2024-07-06T21:35:53.906579Z

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

2024-07-06T21:37:05.633029Z

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

borkdude 2024-07-06T21:38:03.758859Z

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

2024-07-06T21:38:24.187149Z

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

2024-08-01T05:39:27.398569Z

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