Skip to content
Prev 303188 / 398503 Next

Stopping all code execution when ANY error occurs (OR error handling without try/tryCatch)

Hello,

Something like this?


x <- 1:5  # vector with more than one element
# warning, execution continues
if(x == 2) print(2) else print("No!")

ow <- options(warn = 2) # all warnings are now errors
# error, else clause not executed
if(x == 2) print(2) else print("No!")
options(ow)  # reset default warn level


(Another way is the well known print function plus wait for execution to 
stop.)

Hope this helps,

Rui Barradas

Em 12-08-2012 02:56, enocko escreveu: