| try_catch_warnings {EpiForsk} | R Documentation |
Try Catch with Warning Handling
Description
Try Catch with Warning Handling
Usage
try_catch_warnings(expr, character = FALSE)
Arguments
expr |
An expression to be evaluated. |
character |
A logical indicating if the returned error and warning
should be characters ( |
Value
The try_catch_warnings() funciton returns a list with three elements
-
valuesis the evaluatedexprorNULLif the evaluations throws an error. -
warningis any warning given while evaluatingexpr. Whencharacter=FALSE, the default,warningis a simpleWarning, otherwise it is a character. -
erroris any error given while trying to evaluateexpr. Whencharacter=FALSE, the default,erroris a simpleError, otherwise it is a character.
Examples
# No errors or warnings
try_catch_warnings(log(2))
# Warnings
try_catch_warnings(log(-1))
# Errors
try_catch_warnings(stop("Error Message"))
try_catch_warnings(stop("Error Message"), character = TRUE)
[Package EpiForsk version 0.1.1 Index]