The two functions has_warning() and has_error() check if an
expression produces warnings and errors, respectively.
has_warning(expr)
has_error(expr, silent = !interactive())A logical value.
has_warning(1 + 1)
#> [1] FALSE
has_warning(1:2 + 1:3)
#> [1] TRUE
has_error(2 - 3)
#> [1] FALSE
has_error(1 + "a")
#> [1] TRUE
has_error(stop("err"), silent = TRUE)
#> [1] TRUE