Storing console error messages

Is there a better way to trap and show error messages than try catch etc

Basically I want the error messages that appear in the console to be stored in full in a dataframe

Thanks

Hi,

You can easily divert error messages to a text file (which you can later read to data.frame if you wish) using the sink function:

## adapted from sink help file
## 
## capture error messages to a file.
err <- file("Rerrors.txt", open = "wt")
sink(err, type = "message", append = TRUE) # or FALSE if you wish
try(log("a"))
## revert error messages back to the console
sink(type = "message")
file.show("Rerrors.txt")

Hope this helps.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.