Fork me on GitHub

Hi, I'm currently running shadow-cljs but am having some trouble with reading exception messages (no idea of this is shadow-cljs related, just mentioning it) When my code hits the following line: (throw (ex-info (str "Some error") {:info 123} "This is the cause")) I get this error: But the {:info 123} and "This is the cause" is completely omitted.


However when I run this code in the REPL directly, I get the following error, with all the data intact:


Does anyone have an idea why all this extra info is missing?


I think it is because the first case is printed by javascript. The second output is in your devtools console which presents values formatted with shadow-cljs custom formatter. You are throwing a clojurescript error, which is a javascript error with some extra clojurescript data attached. Under normal circumstances, this extra cljs data is presented only with the custom formatter - or you would have to do extra work to print it somehow.


fyi. here is the implementation of devtools formatter installed by shadow-cljs:


@U08E3BBST not sure why thats relevant 😛


just as a proof that it is happening 🙂


@UG9U7TPDZ the repl/invoke shadow-cljs error uses the console to log the error. the other one does not go through "log" and instead is handled by the default handler which just doesn't show the data


@U08E3BBST but the console stuff in shadow-cljs doesn't have any formatter for errors 😛


so there is no custom formatter handling that

😊 1

I see, so I need to add a formatter?


Or just something to handle logging?


no, you need to catch the exception


the actual exception object will have the data stuff


The exception is happening within a library, and it's printing it back with ex-info like I showed in the example code


But isn't ex-info meant to give me extra information?


ex-info is for throwing exception with extra data


ex-data is for getting that data


That makes sense, thanks.


I've got a macro that works in clojure but not in clojurescript, wondering if I'm trying to do something that won't work because of macro differences. the macro generates a comparator based on a set of keys, e.g. (rec-comparator [:k1 :k2]) will expand to (fn [rec1# rec2#] (compare [(:k1 rec1#) (:k2 rec1#)] [(:k1 rec2#) (:k2 rec2#)])) (or something close to that). (sort (rec-comparator [:k1 :k2 :k3]) RECORDS) works in clj, but chokes in cljs, generating a compiler error: java.lang.IllegalArgumentException : Don't know how to create ISeq from: clojure.lang.Symbol .... do macros that generate functions work in clojurescript?


have you looked at the results of macroexpand for both cljs and clj?


just did -- it's expanding to (fn* ([G__...1 G__...2] (compare ...))) ... extra set of parens looks weird, but this is my first attempt at a clojurescript macro


for the macro you're trying to create afaik it shouldn't look any different in clj vs cljs. the extra parens fn is valid syntax in both


just a guess but how did you define the macro? looks like you defined it in CLJS. macros in CLJS need to be defined in CLJ, otherwise they are called as regular functions