Hi,

When using a custom error function that calls q(), what is the recommended way to "flush" the calling function's on.exit ?

For example, say I have a script:

   #!/usr/bin/Rscript --no-init-file

   options(error = function() {

      cat("on error message\n", file = stderr())

      q(save = "no", status = 1)
   })

   test <- function() {

       on.exit(cat("on exit message\n", file = stderr()))

       stop("error")
   }

   test()

when I run the script, the "on exit message" does not print. (I found one solution might involve adding a stop() to my custom error function prior to the q(); however this is somewhat less than ideal: it also triggers an "error during wrapup" because of the recursion).

Other ideas, best practices?

Thanks
Ben

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to