Top: Exceptions and critical errors
Some of the components in Portable Types Library may produce unrecoverable error conditions, such like a string list index is out of bounds, a stream object was constructed with inconsistent parameters, an operation on a stream is requested which requires buffering, etc. These errors are mainly caused by wrong usage of certain objects or functions of PTypes.
Whenever an unrecoverable error condition is raised, PTypes calls fatal() function with a message describing the error condition and terminates the program. On most platforms this message will be sent to stderr, and under Windows the message is shown in a simple dialog box with 'Ok' button. To force Windows version of PTypes to send the message to stderr, compile the library with a conditional symbol NO_CRIT_MSGBOX.
The function fatal() is declared in <pport.h>.
Some library components also raise recoverable error conditions (exceptions). PTypes only generates exception of type exceptobj* defined in <ptypes.h>, or, in some cases, a derivative class, e.g. estream*. An exception object at least contains an error message which can be retrieved through get_message() method. Exception objects are allocated dynamically, and therefore they should be freed by the catch block if it does not pass the exception farther. See also Streams Error handling and Examples.