Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #outer tryCatch, see 1.
- tryCatch({
- #user code block
- #2a. user specific tryCatch, object "vec" not defined
- tryCatch(print(vec),error=function(e) {print("Non-fatal error. Script execution continued.");print(e);})
- #2b. user specific tryCatch
- tryCatch(vec*2)
- #2c. user specific tryCatch
- tryCatch(vec*parameter1, error=function(e) {print("Additional fatal error information. Script execution aborted.");stop(e);})
- #end of user code block
- },
- #outer tryCatch error handler in order to handle fatal errors
- error=function(e) {print("Fatal error");print(e);}
- )
- ourError <-
- function(original, message, class="ourError")
- {
- msg <- paste(message, conditionMessage(original), sep="n ")
- structure(list(message = msg, call = conditionCall(original)),
- class = c(class, class(original)))
- }
- tryCatch(vec*parameter1, error=function(e) {
- err <- ourError(e, "addition fatal info; script aborted")
- stop(err)
- })
- tryCatch({
- tryCatch(stop("oops"), error=function(e) {
- err <- ourError(e, "addition fatal info; script aborted",
- c("fatal", "ourError"))
- stop(err)
- })
- }, ourError=function(err) {
- message("We caught but didn't handle this:n", err)
- }, error =function(err) {
- message("This one got away: ", err)
- })
Add Comment
Please, Sign In to add comment