catchWarning: Return Warning Message in Attribute

View source: R/catchWarning.R

catchWarningR Documentation

Return Warning Message in Attribute

Description

This function evaluates an expression and returns, if warnings occurred, the warning message in the attribute "warningMessage" of the returned object.

Usage

catchWarning(expr, dbg = TRUE)

Arguments

expr

expression to be evaluated

dbg

if TRUE (the default) the warning text is also printed on the console, otherwise the warning message is suppressed.

Examples

catchWarning(as.numeric("1.23"))
result <- catchWarning(as.numeric("x"))
result <- catchWarning(as.numeric("x"), dbg = FALSE)
str(result)

KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.