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
Consider reporting exception cause(s) #1515
Comments
I want to display info about the root cause a try. |
Experimental commit in https://github.com/babashka/babashka/tree/issue-1515
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue
When an uncaught exception occurs, babashka displays the exception but not the cause(s).
This can make troubleshooting difficult.
Realworld Context
We were diagnosing an Etaoin issue.
If Bashashka shared the root cause of the thrown exception, our job would have been easier.
Exploring Current Behaviour
We'll explore current behaviour with a
test.clj
:Babashka Behaviour
Default
We get info on the exception but no info on the cause(s).
With --debug
Does
--debug
provide more info?Applying
--debug
gives us more inner details, but not on the exception cause(s).Clojure Behaviour
Let's take a look at what Clojure does.
Default
Clojure reports on the root cause only by default (with full report to a file).
The Clojure core team feels that the root cause is typically most interesting part of the exception.
What it does not give you is the context that the exception and other causes would provide.
With --report stderr
Let's tell Clojure to send the full report to the terminal instead:
Cool, the report shows all of the causes under
:via
giving us full context.Proposals
There are a many viable ways to address this issue, think of the following options as initial ideas.
Option 1 - Do nothing
Always an option, right?
Option 2 - Add a causes section
Summarize all causes, a mockup of a terse report:
Option 3 - Show the exception and its root cause
Perhaps the most interesting parts of an exception are the exception and its root cause.
Bb is already showing the exception.
It could by default also show the root cause, with the context if possible.
----- Root Cause --------------------------------------------------------------- Type: clojure.lang.ExceptionInfo Message: fn3 badnesss happened Data: {:fn3 :data} Location: /home/lee/proj/oss/-play/bb-cause/test.clj:4:3 ----- Root Cause Context ------------------------------------------------------- 01: (ns test) 02: 03: (defn fn3 [] 04: (throw (ex-info "fn3 badnesss happened" {:fn3 :data}))) ^--- fn3 badness happened 05: 06: (defn fn2 [] 07: (try
Note: if the root cause came from some Java lib, we'd not show the context.
The user might also be interested in other causes, so other options might come into play, but I think maybe showing the exception and root cause might typically be enough info.
Option 4 - Offer full edn report like Clojure does
Mimic Clojure edn report (in a way that makes sense for bb).
Write report to tmp file with option to spit it to terminal.
Option 5 - Spit out causes for --debug
Also spit out info on exception causes when user invokes bb with
--debug
.Option n -
There are many ways to solve this, could convert this to a discussion if that makes sense.
The text was updated successfully, but these errors were encountered: