throwAsCaller
Throw exception as if occurs within calling function
Syntax
Description
Note
In R2022b: throw
is recommended over
throwAsCaller
because it creates the stack trace from
the location where MATLAB® calls the function.
throwAsCaller(
throws an
exception as if it occurs within the calling function. The exception terminates the
currently running function and returns control to the keyboard or an enclosing
exception
)catch
block. When you throw an exception from outside a
try/catch
statement, MATLAB displays the error message in the Command Window.
You can access the MException
object via a
try/catch
statement or the
MException.last
function.
Sometimes, it is more informative for the error to point to the location in the
calling function that results in the exception rather than pointing to the function
that actually throws the exception. You can use throwAsCaller
to
simplify the error display.
Examples
Input Arguments
Extended Capabilities
Version History
Introduced in R2007b
See Also
rethrow
| throw
| MException.last
| try, catch
| error