From luke-tierney at uiowa.edu  Fri Dec  1 23:52:43 2017
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Fri, 1 Dec 2017 16:52:43 -0600 (CST)
Subject: [Rd] tryCatch in on.exit()
In-Reply-To: <CAF8bMcYN35WtHdaYMV8NxL_B9o+dng6PbhqS=UgnYMPvYJy2ZA@mail.gmail.com>
References: <CAF8bMcYN35WtHdaYMV8NxL_B9o+dng6PbhqS=UgnYMPvYJy2ZA@mail.gmail.com>
Message-ID: <alpine.OSX.2.20.1712011652180.1706@lukes-macbook-air.local>

Thanks -- will look into it.

luke

On Fri, 1 Dec 2017, William Dunlap via R-devel wrote:

> The following example involves a function whose on.exit()
> expression both generates an error and catches the error.
> The body of the function also generates an error.
>
> When calling the function wrapped in a tryCatch, should
> that tryCatch's error function be given the error from the
> body of the function, since the one from the on.exit has
> already been dealt with?  Currently the outer tryCatch gets
> the error from the on.exit expression.
>
> xx <- function() {
>  on.exit(tryCatch(
>    expr = stop("error in xx's on.exit"),
>    error=function(e) {
>      cat("xx's on.exit caught error: <<", conditionMessage(e), ">>\n",
> sep="")
>    }))
>  stop("error in body of xx")
> }
> zz <- tryCatch(xx(), error=function(e)paste("outer tryCatch caught error
> <<", conditionMessage(e), ">>", sep=""))
> #xx's on.exit caught error: <<error in xx's on.exit>>
> zz
> #[1] "outer tryCatch caught error <<error in xx's on.exit>>"
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

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



[Rd] tryCatch in on.exit()
luke-tierney at uiowa.edu