I have code in which I am sourcing multiple codes one after the other. Something like below
source("t1.r")
source("t2.r")
source("t3.r")
source("t4.r")
While running this main script if any source statement gives an error, I don't want to source any remaining scripts (i.e. don't want to run any subsequent statements).
I don't want to write if error condition after every source statement. I want to do something universal and at the beginning only.
What change should I do in the main script to do this?
stopfunctionsourcecall 20 times for 20 scripts? Iterate on the scripts names/paths and handle exception within the loop, don't copy/paste as per DRY principles.sourcestatements in a file (say namedall.R), then you runsource("all.R")and it will stop as soon as there is an error. Do you also want to know which script produced the error?