-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better formatting of javascript errors #339
Conversation
Looks good, thanks Aaron! Am hoping to get a chance to cut a new release this weekend. Cheers :-) |
Merging manually now, thanks again (and apologies for the delay!) |
Just happened upon this issue. Since the code comment still asks for alternatives, I would like to mention the formatting function we've been using quite successfully so far: (defn format-error [err]
(str (.-stack err) ; includes `ex-message`
(when-let [d (ex-data err)]
(str "\nex-data\n " (pr-str d)))
(when-let [c (ex-cause err)]
(str "\ncaused by - " (format-error c))))) As you can see, it also walks the cause chain and prints |
@DerGuteMoritz yeah this function is even better. Do you want to submit a PR for this, or if you'd like I can copy/paste it into my PR. |
Oh I just realized my PR was already merged. In any case, this function seems like an improvement, perhaps @DerGuteMoritz you can submit a PR with it? |
Sure thing, here you go! Adjusted it to also use |
…uteMoritz) Changes: - Print ex-data - Print full cause chain
…uteMoritz) Changes: - Print ex-data - Print full cause chain
…uteMoritz) Changes: - Print ex-data - Print full cause chain
…eMoritz) Changes incl.: - Print ex-data - Print full cause chain Changes will affect all Cljs users of the default output fn (and/or the default error fn), i.e. most Cljs users. Since the effect of these changes is just additional information in logging output, my hope is that the change should be a positive or neutral one for the vast majority of users. To customise error formating, see the `default-output-fn` docstring.
I think in javascript land, we want to show the stringified error (which contains the type of error and err.message, both important pieces of info) as well as the stacktrace if it exists.