Fix exception handling under MATLAB in unitary test infrastructure.

The getReport() function of MATLAB expects an exception coming from the "catch"
statement. It is not happy with the value returned by lasterror().

(cherry picked from commit 8daed40ab39d9a4ca01d280158539864a0197037)