You are catching the error, without doing anything with the encountered error. Instead, catch the exception and display it. In a script/function this would look like:
try
someNonExistingFunction()
catch ME
disp(ME)
end
Which will display the following:
ME =
MException with properties:
identifier: 'MATLAB:UndefinedFunction'
message: 'Undefined function or variable 'someNonExistingFunction'.'
cause: {}
stack: [0×1 struct]
Correction: []
When calling from bash, you could do this:
matlab -nodisplay -r "try; someFunction(); catch ME; disp(ME); end; quit"
This will make sure that you do see the error message (and the line the error occured if you display ME.stack), but allows to execute the last quit statement.