Skip to content
Prev 284924 / 398502 Next

Find exit status inside on.exit

Hello,
Does anyone know if it is possible to find out whether a calling function exited with an error or not inside of an on.exit() call? I'd like to use the same error cleanup function inside of several functions, and for aesthetic reasons would prefer not to surround the body of all of these function with a tryCatch.

Something like this:

isError <- function() {
        parentError <- ???
        if (!parentError) cat("No errors here!\n")
}

X <- function() {
        on.exit(isError())
        1+1
}
[1] 2
No errors here!

Thanks,
Robert

Robert McGehee, CFA
Geode Capital Management, LLC
One Post Office Square, 28th Floor | Boston, MA | 02109
Direct: (617)392-8396

This e-mail, and any attachments hereto, are intended fo...{{dropped:10}}