How can I make sure that after I \"catch\" an error and log it no further code steps are executed (I do not want to use q())?
My usage scenario is like this: - do so
Just wrap curly braces around it
> {
+ handleMySimpleError<-function(e, text) {
+ # Let's log the error
+ print(paste0(text, ": ", e))
+ # This should stop execution of any further steps but it doesn't
+ stop("Now, stop. For real.")
+ }
+ print("Starting execution...")
+ tryCatch(
+ stop("My simple error."),
+ error=function(e) {handleMySimpleError(e, "could not finish due to")}, finally=NULL
+ )
+ print("Successfully ended execution...")
+ }
[1] "Starting execution..."
[1] "could not finish due to: Error in doTryCatch(return(expr), name, parentenv, handler): My simple error.\n"
Error in handleMySimpleError(e, "could not finish due to") :
Now, stop. For real.