throw(exception)
throw(
throws
an exception based on the information contained in the exception
)MException
object, exception
.
The exception terminates the currently running function and returns
control either to the keyboard or to an enclosing catch
block.
When you throw an exception from outside a try/catch
statement, MATLAB® displays
the error message in the Command Window.
The throw
method, unlike the throwAsCaller
and rethrow
methods,
creates the stack trace from the location where MATLAB executes
the method.
You can access the MException
object via a try/catch
statement
or the MException.last
method.
error
| MException
| MException.addCause
| MException.getReport
| MException.last
| MException.rethrow
| MException.throwAsCaller
| try, catch