tcmsg: tryCatch with Message

View source: R/tcmsg.R

tcmsgR Documentation

tryCatch with Message

Description

Easy Try/Catch implementation to return the same message on error or warning. Makes it easier to write tryCatches. Author: Bryce Chamberlain. Tech review: Lindsay Smelzter.

Usage

tcmsg(code_block, ...)

Arguments

code_block

Code to run in Try Catch.

...

Strings to concatenate to form the message that is returned.

Examples

tryCatch({ 
   tcmsg({ NULL = 1 }, 'Cannot assign to NULL','variable' ) 
 }, 
 error = function(e) print( e ) 
 )

tryCatch({ 
   tcmsg({ as.numeric('abc') },'Issue in as.numeric()') 
  }, 
  warning = function(e) print( e ) 
)

oliver-wyman-actuarial/easyR documentation built on Jan. 27, 2024, 4:35 a.m.