Skip to Main Content Skip to Search
Product Documentation

rethrow - Reissue error

Syntax

rethrow(errorStruct)

Description

rethrow(errorStruct) reissues the error specified by errorStruct. The currently running function terminates and control returns to the keyboard (or to any enclosing catch block). The errorStruct argument must be a MATLAB structure containing at least the message and identifier fields:

Fieldname

Description

message

Text of the error message

identifier

Message identifier of the error message

stack

Information about the error from the program stack

See "Message Identifiers" in the MATLAB documentation for more information on the syntax and usage of message identifiers.

Tips

The errorStruct input can contain the field stack, identical in format to the output of the dbstack command. If the stack field is present, the stack of the rethrown error will be set to that value. Otherwise, the stack will be set to the line at which the rethrow occurs.

Examples

rethrow is usually used in conjunction with try-catch statements to reissue an error from a catch block after performing catch-related operations. For example,

try
   do_something
catch
   do_cleanup
   rethrow(previous_error)
end

See Also

assert | catch | dbstop | error | rethrow(MException) | throw(MException) | throwAsCaller(MException) | try

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS