ftry: Wrap a try block in futile.logger

Description Usage Arguments Author(s) Examples

View source: R/logger.R

Description

This function integrates futile.logger with the error and warning system so problems can be caught both in the standard R warning system, while also being emitted via futile.logger.

Usage

1
ftry(expr, error = stop, finally = NULL, silent = FALSE, details = "")

Arguments

expr

The expression to evaluate in a try block

error

An error handler

finally

Pass-through to tryCatch finally

silent

Boolean - should errors be rethrown? The same as the silent option on 'try'. If a custom error handler is being used that takes control over this option. Note you should test the return value if you are dependent on it.

details

An extra string to print when there's a warning message

Author(s)

Brian Lee Yung Rowe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
ftry(log("a")) # Logs the warning (but the warning still bubbles)

x <- 'a'
y <- 2 # Some ID associated with x value
ftry(log("a"), details=sprintf("y = %s",y))

ftry(log(-1)) # Logs the error and rethrows it

## End(Not run)
ftry(log(-1),silent=TRUE) # logs the error and silently continues

zatonovo/futile.logger documentation built on Feb. 23, 2022, 10:18 p.m.