Skip to contents

Capture all errors, warnings and messages

Usage

purely(.f)

Arguments

.f

A function to decorate

Value

A function which returns a list. The first element of the list, $result, is the result of the original function .f applied to its inputs. The second element, $log is NULL in case everything goes well. In case of error/warning/message, $result is NA and and $log holds the message. purely() is used by loudly() to allow the latter to handle errors.

Examples

purely(log)(10)
#> $result
#> [1] 2.302585
#> 
#> $log
#> [1] NA
#> 
purely(log)(-10)
#> $result
#> [1] NA
#> 
#> $log
#> [1] "NaNs produced"
#>