Skip to content

how to clear the last error?

2 messages · Adrian Dragulescu, Duncan Murdoch

#
Hello,

I would like to clear the last error that I get with geterrmessage().  Not
even rm(list=ls()) clears it.  Can I set it to NULL somehow?

Thank you,
Adrian
#
On 2/9/2006 11:11 AM, Adrian Dragulescu wrote:
Not from R, but there is a C-level way to do it in src/main/errors.c. 
It's marked as "temporary", but it's been there since R 1.3.x.

The declaration is

void R_SetErrmessage(char *s);

Alternatively, you could just cover up the last error with a new one by 
calling stop, e.g.

 > try(stop(""),TRUE)
 > geterrmessage()
[1] "Error in try(stop(\"\"), TRUE) : \n"

Duncan Murdoch