Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tryCatchWEM

Try functions to capture warnings, errors and messages.


Description

This function combines the base functions tryCatch() and withCallingHandlers() for the specific purpose of capturing not only errors and warnings but messages as well.

Usage

tryCatchWEM(expr, capture = FALSE)

Arguments

expr

Expression to be evaluated.

capture

Logical, capture the visible output.

Details

In some situations it might be important not only to test a function, but also to capture everything that is written in the R console, be it an error, a warning or simply a message.

For instance package QCA (version 3.4) has a Graphical User Interface that simulates an R console embedded into a web based shiny app.

It is not intended to replace function tryCatch() in any way, especially not evaluating an expression before returning or exiting, it simply captures everything that is printed on the console (the visible output).

Value

A list, if anything would be printed on the screen, or an empty (NULL) object otherwise.

Author(s)

Adrian Dusa


admisc

Adrian Dusa's Miscellaneous

v0.12
GPL (>= 3)
Authors
Adrian Dusa [aut, cre, cph] (<https://orcid.org/0000-0002-3525-9253>)
Initial release
2021-03-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.