EVOLUTION-MANAGER
Edit File: entrace.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Add backtrace from error handler</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for entrace {rlang}"><tr><td>entrace {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add backtrace from error handler</h2> <h3>Description</h3> <p><code>entrace()</code> is a low level function. See <code><a href="global_entrace.html">global_entrace()</a></code> for a user-friendly way of enriching errors and other conditions from your RProfile. </p> <ul> <li> <p><code>entrace()</code> is meant to be used as a global handler. It enriches conditions with a backtrace. Errors are saved to <code><a href="last_error.html">last_error()</a></code> and rethrown immediately. Messages and warnings are recorded into <code><a href="last_warnings.html">last_messages()</a></code> and <code><a href="last_warnings.html">last_warnings()</a></code> and let through. </p> </li> <li> <p><code>cnd_entrace()</code> adds a backtrace to a condition object, without any other effect. It should be called from a condition handler. </p> </li></ul> <p><code>entrace()</code> also works as an <code>option(error = )</code> handler for compatibility with versions of R older than 4.0. </p> <p>When used as calling handler, rlang trims the handler invokation context from the backtrace. </p> <h3>Usage</h3> <pre> entrace(cnd, ..., top = NULL, bottom = NULL) cnd_entrace(cnd, ..., top = NULL, bottom = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>cnd</code></td> <td> <p>When <code>entrace()</code> is used as a calling handler, <code>cnd</code> is the condition to handle.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Unused. These dots are for future extensions.</p> </td></tr> <tr valign="top"><td><code>top</code></td> <td> <p>The first frame environment to be included in the backtrace. This becomes the top of the backtrace tree and represents the oldest call in the backtrace. </p> <p>This is needed in particular when you call <code>trace_back()</code> indirectly or from a larger context, for example in tests or inside an RMarkdown document where you don't want all of the knitr evaluation mechanisms to appear in the backtrace. </p> <p>If not supplied, the <code>rlang_trace_top_env</code> global option is consulted. This makes it possible to trim the embedding context for all backtraces created while the option is set. If knitr is in progress, the default value for this option is <code>knitr::knit_global()</code> so that the knitr context is trimmed out of backtraces.</p> </td></tr> <tr valign="top"><td><code>bottom</code></td> <td> <p>The last frame environment to be included in the backtrace. This becomes the rightmost leaf of the backtrace tree and represents the youngest call in the backtrace. </p> <p>Set this when you would like to capture a backtrace without the capture context. </p> <p>Can also be an integer that will be passed to <code><a href="stack.html">caller_env()</a></code>.</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="global_entrace.html">global_entrace()</a></code> for configuring errors with <code>entrace()</code>. <code><a href="entrace.html">cnd_entrace()</a></code> to manually add a backtrace to a condition. </p> <h3>Examples</h3> <pre> quote({ # Not run # Set `entrace()` globally in your RProfile globalCallingHandlers(error = rlang::entrace) # On older R versions which don't feature `globalCallingHandlers`, # set the error handler like this: options(error = rlang::entrace) }) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>