4.3. The OCI_Error Class

Refer to Section 4.2 for the public data members and member functions which are inherited by OCI_Error.


Figure 4-2. class OCI_Error

namespace Oracle
{
    struct OCI_Error: public Error
    {
        // constructors
        OCI_Error(
	    const string&,
            OCIError*,
            const string& = "",
            const int = 0);

	// data members
	int ora_code;
    };
}

4.3.1. Public Member Functions

4.3.1.1. Constructors

OCI_Error(const string& module_name, OCIError* error_handle, const string& file_name, const int line_number);

When you throw an OCI_Error object, you specify the module_name and the error_handle, and optionally the file_name and line_number. You may specify the file name and line number using the pre-defined macros __FILE__ and __LINE__.

If you wish to provide addtional information, such as the names and values of local variables, you may write to the desc data member (Section 4.2.2.5) as you would any output stream.

The OCI_Error constructor uses the OCI error handle to find the Oracle error number and message. The msg data member is set to the Oracle error message, and ora_code is set to the error code.

4.3.2. Public Data Members

4.3.2.1. msg

This data member is inherited from the Error class and contains an Oracle error message rather than a value supplied to the constructor.

4.3.2.2. ora_code

This is the Oracle error code.