summaryrefslogtreecommitdiff
path: root/devdocs/elisp/error-debugging.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/error-debugging.html')
-rw-r--r--devdocs/elisp/error-debugging.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/devdocs/elisp/error-debugging.html b/devdocs/elisp/error-debugging.html
new file mode 100644
index 00000000..2bf86942
--- /dev/null
+++ b/devdocs/elisp/error-debugging.html
@@ -0,0 +1,26 @@
+ <h4 class="subsection">Entering the Debugger on an Error</h4> <p>The most important time to enter the debugger is when a Lisp error happens. This allows you to investigate the immediate causes of the error. </p> <p>However, entry to the debugger is not a normal consequence of an error. Many commands signal Lisp errors when invoked inappropriately, and during ordinary editing it would be very inconvenient to enter the debugger each time this happens. So if you want errors to enter the debugger, set the variable <code>debug-on-error</code> to non-<code>nil</code>. (The command <code>toggle-debug-on-error</code> provides an easy way to do this.) </p> <dl> <dt id="debug-on-error">User Option: <strong>debug-on-error</strong>
+</dt> <dd>
+<p>This variable determines whether the debugger is called when an error is signaled and not handled. If <code>debug-on-error</code> is <code>t</code>, all kinds of errors call the debugger, except those listed in <code>debug-ignored-errors</code> (see below). If it is <code>nil</code>, none call the debugger. </p> <p>The value can also be a list of error conditions (see <a href="signaling-errors">Signaling Errors</a>). Then the debugger is called only for error conditions in this list (except those also listed in <code>debug-ignored-errors</code>). For example, if you set <code>debug-on-error</code> to the list <code>(void-variable)</code>, the debugger is only called for errors about a variable that has no value. </p> <p>Note that <code>eval-expression-debug-on-error</code> overrides this variable in some cases; see below. </p> <p>When this variable is non-<code>nil</code>, Emacs does not create an error handler around process filter functions and sentinels. Therefore, errors in these functions also invoke the debugger. See <a href="processes">Processes</a>. </p>
+</dd>
+</dl> <dl> <dt id="debug-ignored-errors">User Option: <strong>debug-ignored-errors</strong>
+</dt> <dd>
+<p>This variable specifies errors which should not enter the debugger, regardless of the value of <code>debug-on-error</code>. Its value is a list of error condition symbols and/or regular expressions. If the error has any of those condition symbols, or if the error message matches any of the regular expressions, then that error does not enter the debugger. </p> <p>The normal value of this variable includes <code>user-error</code>, as well as several errors that happen often during editing but rarely result from bugs in Lisp programs. However, “rarely” is not “never”; if your program fails with an error that matches this list, you may try changing this list to debug the error. The easiest way is usually to set <code>debug-ignored-errors</code> to <code>nil</code>. </p>
+</dd>
+</dl> <dl> <dt id="eval-expression-debug-on-error">User Option: <strong>eval-expression-debug-on-error</strong>
+</dt> <dd>
+<p>If this variable has a non-<code>nil</code> value (the default), running the command <code>eval-expression</code> causes <code>debug-on-error</code> to be temporarily bound to <code>t</code>. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html#Lisp-Eval">Evaluating Emacs Lisp Expressions</a> in <cite>The GNU Emacs Manual</cite>. </p> <p>If <code>eval-expression-debug-on-error</code> is <code>nil</code>, then the value of <code>debug-on-error</code> is not changed during <code>eval-expression</code>. </p>
+</dd>
+</dl> <dl> <dt id="debug-on-signal">User Option: <strong>debug-on-signal</strong>
+</dt> <dd>
+<p>Normally, errors caught by <code>condition-case</code> never invoke the debugger. The <code>condition-case</code> gets a chance to handle the error before the debugger gets a chance. </p> <p>If you change <code>debug-on-signal</code> to a non-<code>nil</code> value, the debugger gets the first chance at every error, regardless of the presence of <code>condition-case</code>. (To invoke the debugger, the error must still fulfill the criteria specified by <code>debug-on-error</code> and <code>debug-ignored-errors</code>.) </p> <p>For example, setting this variable is useful to get a backtrace from code evaluated by emacsclient’s <samp>--eval</samp> option. If Lisp code evaluated by emacsclient signals an error while this variable is non-<code>nil</code>, the backtrace will popup in the running Emacs. </p> <p><strong>Warning:</strong> Setting this variable to non-<code>nil</code> may have annoying effects. Various parts of Emacs catch errors in the normal course of affairs, and you may not even realize that errors happen there. If you need to debug code wrapped in <code>condition-case</code>, consider using <code>condition-case-unless-debug</code> (see <a href="handling-errors">Handling Errors</a>). </p>
+</dd>
+</dl> <dl> <dt id="debug-on-event">User Option: <strong>debug-on-event</strong>
+</dt> <dd><p>If you set <code>debug-on-event</code> to a special event (see <a href="special-events">Special Events</a>), Emacs will try to enter the debugger as soon as it receives this event, bypassing <code>special-event-map</code>. At present, the only supported values correspond to the signals <code>SIGUSR1</code> and <code>SIGUSR2</code> (this is the default). This can be helpful when <code>inhibit-quit</code> is set and Emacs is not otherwise responding. </p></dd>
+</dl> <dl> <dt id="debug-on-message">Variable: <strong>debug-on-message</strong>
+</dt> <dd><p>If you set <code>debug-on-message</code> to a regular expression, Emacs will enter the debugger if it displays a matching message in the echo area. For example, this can be useful when trying to find the cause of a particular message. </p></dd>
+</dl> <p>To debug an error that happens during loading of the init file, use the option ‘<samp>--debug-init</samp>’. This binds <code>debug-on-error</code> to <code>t</code> while loading the init file, and bypasses the <code>condition-case</code> which normally catches errors in the init file. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Error-Debugging.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Error-Debugging.html</a>
+ </p>
+</div>