I am looking for an elegant way to use a conditional try catch statement.
I suppose it could look something like this:
tryif loose==1
% Do something, like loading the user preferences
catch %Or catchif?
% Hande it
end
So far I know that you can use try catch blocks to let your compiled code run, but force it to stop in a debug session with dbstop if caught error. Now I am basically looking for the opposite:
Normally I want the code to stop if unexpected situations occur (to guarantee the integrity of results) but want to be less strict about certain things sometimes when I am debugging.
tryifandcatchifstatements. FortryifI imagine it would not try the code, whereas withcatchifit would always try, but not always catch. Are you aftercatchif?Do something, but just want to controll whether I am forgiving when it fails. The accepted answer seems to be exactly what I was looking for.