From dhinds at sonic.net  Wed Oct  4 02:32:34 2006
From: dhinds at sonic.net (dhinds at sonic.net)
Date: Wed,  4 Oct 2006 02:32:34 +0200 (CEST)
Subject: [Rd] Bug in warning() for condition objects (PR#9274)
Message-ID: <20061004003234.1973A49FDD@slim.kubism.ku.dk>

Full_Name: David Hinds
Version: 2.4.0
OS: Windows XP
Submission from: (NULL) (64.168.232.238)


A (maybe naive) use of tryCatch to trap errors and report as warnings does not
work, i.e.:

  x <- tryCatch(lm(xyzzy), error=warning)

In src/library/base/R/stop.R, the warning() function contains the following
code, for handling condition objects:

        withRestarts({
            .Internal(.signalCondition(cond, message, call))
            .Internal(.dfltStop(message, call))
        }, muffleWarning = function() NULL)

So all conditions result in calling .dfltStop().  It would seem more useful
and/or consistent for warning() to call .dfltWarn(), or in the alternative, to
choose between .dfltStop and .dfltWarn based on the class of the condition
object.




[Rd] Bug in warning() for condition objects (PR#9274)
dhinds at sonic.net