Exception handling


Detailed Description

Exception handlers are created and caught using the exception module.

Note that the exception handlers are only necessary for C code. This will usually by something like this:

    TRY {
        // some code...
        if (errno)
            THROW("Error %d: %s", errno, strerror(errno));
        // more code...
    } CATCH(char *msg) {
        output_error("Exception caught: %s", msg);
    } ENDCATCH

In C++ code, you can use THROW() to throw an exception that is to be caught by the main system exception handler.

The recommended format for exception messages is as follows:


Typedefs

typedef struct s_exception_handler EXCEPTIONHANDLER
 the exception handler structure

Functions

EXCEPTIONHANDLERcreate_exception_handler (void)
 Creates an exception handler for use in a try block.
void delete_exception_handler (EXCEPTIONHANDLER *ptr)
 Deletes an exception handler from the handler list.
char * exception_msg (void)
 Retrieves the message of the most recently thrown exception.
void throw_exception (char *format,...)
 Throw an exception.


Function Documentation

EXCEPTIONHANDLER * create_exception_handler ( void   ) 

Creates an exception handler for use in a try block.

Returns:
a pointer to an EXCEPTIONHANDLER structure

Definition at line 64 of file exception.c.

References output_fatal().

void delete_exception_handler ( EXCEPTIONHANDLER ptr  ) 

Deletes an exception handler from the handler list.

Parameters:
ptr  a pointer to the exception handler

Definition at line 80 of file exception.c.

References output_fatal().

char * exception_msg ( void   ) 

Retrieves the message of the most recently thrown exception.

Returns:
a char* pointer to the message

Definition at line 129 of file exception.c.

void throw_exception ( char *  format,
  ... 
)


GridLAB-DTM Version 2.0
An open-source project initiated by the US Department of Energy