2.6 Exceptions and Error Handling

All Sh errors are represented by exception classes. All of these classes derive from ShException, which primarily just provides a single message explaining the error. This message can be obtained by calling the message() member function.

Errors are raised by calling the global shError() function. This function checks the current ShContext’s throw_errors() setting. If this is true (which is the default) it will throw an exception. / E  Otherwise it will merely output the message on std::cerr and continue as if no error happened.

If throw_errors() is turned off, the system may be in an inconsistent state after an error occurs. We recommend that all errors be caught as exceptions.


Note: This manual is available as a bound book from AK Peters, including better formatting, in-depth examples, and about 200 pages not available on-line.