- Clean up any unwanted side effects of the error.
When you reach the end of the catch block, you can either continue executing the
program, if possible, or terminate it.
The documentation on “Capture Information About Exceptions” on page 26-5 describes
how to acquire information about what caused the error, and “Respond to an Exception”
on page 26-19 presents some ideas on how to respond to it.
Generating a New Exception
When your program code detects a condition that will either make the program fail or
yield unacceptable results, it should throw an exception. This procedure
- Saves information about what went wrong and what code was executing at the time of
the error. - Gathers any other pertinent information about the error.
- Instructs MATLAB to throw the exception.
The documentation on “Capture Information About Exceptions” on page 26-5 describes
how to use an MException object to capture information about the error, and “Throw an
Exception” on page 26-16 explains how to initiate the exception process.
26 Error Handling