Message-ID: <17B09E7789D3104E8F5EEB0582A8D66FBAA37CB386@MSGRTPCCRF2WIN.DMN1.FMR.COM>
Date: 2012-02-10T17:07:29Z
From: McGehee, Robert
Subject: 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
}
> X()
[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}}