shims: Enable and Disable Warning or Error Capture

Description Usage Arguments Details Error Shim Warning Shim Author(s) See Also Examples

Description

Add or remove a listener to top-level task callbacks that checks for whether a new warning or error occurs and then triggers a search browser.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
enable_warning_shim(
  warning_search_func = getOption("errorist.warning", searcher::search_google)
)

disable_warning_shim()

enable_error_shim(
  error_search_func = getOption("errorist.error", searcher::search_google)
)

disable_error_shim()

Arguments

error_search_func, warning_search_func

The search function from searcher that should be called when an error or warning occurs. By default, searches are routed through Google.

Details

By default, both enable_warning_shim() and enable_error_shim() functions are automatically triggered when the errorist package is loaded.

Error Shim

The error shim uses R's default handler for errors set by specifying a function for error in options().

Warning Shim

For the warning shim, a top-level task callback added to the environment via base::addTaskCallback(). This causes the warning handler to fire each time a new function call occurs in R regardless of whether it triggers an error.

Author(s)

James Joseph Balamuta

See Also

base::addTaskCallback()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Default setup
enable_warning_shim()

# Some code ...

# Remove the shim
disable_warning_shim()

# Specify a search function
enable_warning_shim(warning_search_func = searcher::search_google)

# Some code ...

# Remove the shim
disable_warning_shim()

# Enable only the error shim
enable_error_shim()

# Some code ...

# Remove the shim
disable_error_shim()

# Specify a search function
enable_error_shim(error_search_func = searcher::search_google)

# Some code ...

# Remove the shim
disable_error_shim()

errorist documentation built on Feb. 24, 2020, 9:07 a.m.