[R] signalCondition

Luke Tierney luke at stat.uiowa.edu
Mon Nov 10 15:50:28 CET 2003


On Sun, 9 Nov 2003, Hadley Wickham wrote:

> Does signalCondition() only work within try-catch blocks?
> 
> I expected:
> 
> testSignal <- function() {
>     error <- simpleError("An error!")
>     signalCondition(error)
> }
> 
> to do the same thing as
> 
> testStop <- function() {
>     error <- simpleError("An error!")
>     stop(error)
> }
> 
> but testSignal returns NULL without throwing an error.  Have I 
> misunderstood something?

signalCondition does not throw an error it just runs handlers if any
are available.  If none are available or all the available ones are
calling handlers that return normally, then signalCondition will
return NULL.  Conceptually, signalCondition is a lower level mechainsm
on which stop and warning are built.  stop roughly corresponds to a
call to signalCondition followed by the defaul error handling code.
If a handler established by tryCatch is available, then
signalCondition will transfer control to that handler and the default
code is not reached.

Hope that helps,

luke

-- 
Luke Tierney
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
   Actuarial Science
241 Schaeffer Hall                  email:      luke at stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu




More information about the R-help mailing list