global_entrace() enriches base errors with rlang features:

  • They are assigned a backtrace. You can configure whether to display a backtrace on error with the rlang_backtrace_on_error global option.

  • They are recorded in last_error(). Calling this function is another way of inspecting the backtrace.

When global entracing is enabled, all errors behave as if they had been thrown with abort(), even the ones thrown with stop() or from native code.

Set global entracing in your RProfile with:

global_entrace(enable = TRUE, class = c("error", "warning", "message"))



Whether to enable or disable entracing.


A character vector of one or several classes of conditions to be entraced.

Under the hood

On R 4.0 and newer, global_entrace() installs a global handler with globalCallingHandlers(). On older R versions, entrace() is set as an option(error = ) handler. The latter method has the disadvantage that only one handler can be set at a time. This means that you need to manually switch between entrace() and other handlers like recover(). Also this causes a conflict with IDE handlers (e.g. in RStudio).