Re: [Rd] Resume processing after warning handler.

From: Titus von der Malsburg <malsburg_at_gmail.com>
Date: Mon, 06 Feb 2012 13:46:40 +0100

On Sat, Feb 4, 2012 at 4:37 PM, Martin Morgan <mtmorgan_at_fhcrc.org> wrote:
> On 02/03/2012 02:49 AM, Titus von der Malsburg wrote:
> Hi Titus -- use withCallingHandlers to capture the warning, and
> invokeRestart() to continue after handling it.
>
> withCallingHandlers({
>    warning('oops')
>    message('continuing')
> }, warning=function(w) {
>    message('handling: ', conditionMessage(w))
>    invokeRestart("muffleWarning")
> })

Thanks Martin! This is exactly what I was looking for. I saw the invocation of muffledWarning in a few places when I googled warning and error handlers but unfortunately I couldn't find explanations and documentation about it. When I invoked muffledWarning in a warning handler for tryCatch, I got a message saying that there's no restart named like that. MuffledWarning is not mentioned in the man page of withCallingHandlers. Also, figuring out basic stuff like that you can add warning and error arguments to tryCatch was also not so easy. Is there a document somewhere that explains handling of errors and warnings in detail?

  Titus



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 06 Feb 2012 - 12:50:01 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 06 Feb 2012 - 20:50:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive