Main Content
throw
Throw exception
Syntax
Description
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
function, unlike the throwAsCaller
and rethrow
functions, creates the stack trace from the
location where MATLAB calls the function.
You can access the MException
object via a try/catch
statement or the MException.last
function.
Examples
Input Arguments
Extended Capabilities
Version History
Introduced in R2007b
See Also
rethrow
| throwAsCaller
| MException.last
| try,
catch
| error