Skip to content

Debug on exception #3337

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cider-eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,9 @@ command `cider-debug-defun-at-point'."
(when inline-debug
(cider--prompt-and-insert-inline-dbg)))
(cider-interactive-eval (when (and debug-it (not inline-debug))
(concat "#dbg\n" (cider-defun-at-point)))
(if (eq '- debug-it)
(concat "#dbgexn\n" (cider-defun-at-point))
(concat "#dbg\n" (cider-defun-at-point))))
nil
(cider-defun-at-point 'bounds)
(cider--nrepl-pr-request-map))))
Expand Down
13 changes: 13 additions & 0 deletions doc/modules/ROOT/pages/debugging/debugger.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ plus metadata annotation in your code. Note that you'll have to delete
this annotation by hand; you cannot simply use kbd:[C-M-x] as you
can to un-instrument kbd:[C-u C-M-x].

== Debug on Exception

There is basic experimental support for entering the debugger when an exception
is thrown. When you instrument a function by passing a negative argument to
`cider-eval-defun-at-point` kbd:[C-u - C-M-x] then you will enter the debugger
whenever any form in that function throws an exception. You can also instrument
a form manually by placing `#exn` in front to instrument just that form, or
`#dbgexn` to instrument every form inside of it, the same difference as between
`#break` and `#dbg`. This is mostly useful to see the values of local variables at
the time of the exception. *locals*, *eval*, and *inject* all work as expected,
while *continue* or *next* will simply rethrow the exception, exiting the
debugger.

== Caveats

Due to the way the debugger is currently implemented there are some
Expand Down