[R] R-Embedding and error messages
Martin Morgan
mtmorgan at fhcrc.org
Wed Aug 20 19:05:12 CEST 2008
Hi Jorge --
I hesitate to suggest this unsupported solution (as these public
suggestions tend to mean that the solution disappears!), but in C
extern void R_SetErrorHook(void (*)(SEXP, char *));
void
my_ErrorHook(SEXP call, char *message)
{
/*
etc; e.g., cache message, perhaps reset error hook (hook is
removed after error; nested R-level try() may mean multiple
errors per R_tryEval?
*/
}
and then
...
R_SetErrorHook( my_ErrorHook );
PROTECT(value = R_tryEval( expr, env, errorOccurred ));
if( *errorOccurred ) {
/* etc, e.g., retrieve error message(s) from cache */
}
/*
hmm, maybe R_SetErrorHook needs to be cleared here, or at
least replaced with a no-op?
*/
...
This is an R-devel question, not R-help.
Martin
"Jorge W. Cardoso" <cardoso at montevideo.com.uy> writes:
> I'm writing a C++ application using R-embedding to do some
> forecast process.
>
> I also use R_tryEval instead of R_Eval to run my R-script,
> so that in case of error I know exactly in which line number
> was the last error.
>
> In particular, from time in time y get some error messages
> refering an exceptional condition in the arima model.
>
> I want to catch these error messages from de C code
> (or at least the code error number) to take some
> corrective actions.
>
> Is there any way to do that ?
>
> Regards,
>
> Jorge W. Cardoso
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M2 B169
Phone: (206) 667-2793
More information about the R-help
mailing list