| Using the C++ Math Library | ![]() |
Errors
The MATLAB C++ Math Library uses C++ exceptions to report errors. The MATLAB C++ Math Library divides the errors it reports into categories and for each of these categories it provides a class. All of the exception classes are subclasses of mwException. Because all the exceptions are derived from the same superclass, it is easy to write a general exception handler. For example:
try {
// Some MATLAB C++ Math Library code
}
catch(mwException &ex) {
cout << ex << endl;
}
This try-catch block catches any exception that occurs during the execution of the indicated MATLAB C++ Math Library code and prints the error message associated with the exception to standard output. You should put a try-catch block like this one in every main() routine you write.
See Handling Exceptions in Chapter 7 for more information on the error handling mechanism and Appendix C for a list of the library's error messages.
| Input and Output | Memory Management | ![]() |