MATLAB: Rethrow a whole error as warning

errorerror handlingexceptionsrethrowtry/catchwarning

Hi all
I use a try-catch to capture error information and rethrow it as a warning to prevent program termination:
% stuff
try
% do stuff
catch ME
warning(ME.message)
continue
end
% do other stuff
However, by using warning(ME.message) you do not get all error messages.
Alternatively, if you use rethrow(ME) you do get all the error messages (including functions and lines), but you terminate the running program.
Is there a way to get the same messages you get with rethrow(ME) without terminating the running program?
Thanks for your help.

Best Answer

Yes, an alternative is
try
% do stuff
catch me
disp( getReport( me, 'extended', 'hyperlinks', 'on' ) )
end
getReport is "documented"
>> help getReport
--- help for MException/getReport ---
getReport Get error message for exception.
REPORT = getReport(ME) returns a formatted message string based on the
....
Why continue?