throw
Raises an MException object as an error.
Category: Programming > Programming Utilities
Syntax
throw(ME)
Stops execution with the exception ME, as if error had been called.
Description
throw is the way to raise an exception that was built ahead of time with MException and possibly extended with addCause. The error propagates up the call stack until a try/catch handles it.
Input arguments
ME- An
MExceptionobject.
Example
Throwing a prepared exception
ME = MException('check:neg', 'Negative value: %d', -4);
try
throw(ME)
catch err
fprintf('%s | %s\n', err.identifier, err.message)
end
Output
check:neg | Negative value: -4