ICLibErrorInfo

The ICLibErrorInfo class represents error information. When a C library call results in an error condition, objects of the ICLibErrorInfo class are created. The per thread global variable errno is used to obtain the error text.

The Open Class Library provides the ITHROWCLIBERROR macro for throwing exceptions constructed with ICLibErrorInfo information. This macro has the following parameters:

location
The name of the C function returning the error code, the name of the file the function is in, and the function's line number.
name
Use the enumeration IBaseErrorInfo::ExceptionType to specify the type of the exception. The default is accessError.
severity
Use the enumeration IException::Severity to specify the severity of the error. The default is recoverable.

This macro generates code that calls throwCLibError, which does the following:

  1. Creates an ICLibErrorInfo object
  2. Uses the object to create an IException object
  3. Adds the CLibrary error group to the object
  4. Adds location information
  5. Logs the exception data
  6. Throws the exception


ICLibErrorInfo - Member Functions and Data by Group

Constructors & Destructor

You can construct and destruct objects of this class. You cannot copy or assign objects of this class.


[view class]
~ICLibErrorInfo
public:
virtual ~ICLibErrorInfo()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
ICLibErrorInfo
public:
ICLibErrorInfo(const char* CLibFunctionName = 0)

You can only construct objects of this class using the default constructor.
Note: If the constructor cannot load the error text, the Open Class Library provides the following default text: "No error text is available."

CLibFunctionName
The name of the failing C library function. If you specify CLibFunctionName, the constructor prefixes it to the error text. Optional.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Error Information

Use these members to return the error information provided by objects of this class.


[view class]
errorId
public:
virtual unsigned long errorId() const

Returns the value of errno, which you can use to obtain the errno information.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
isAvailable
public:
virtual bool isAvailable() const

If the error text is available, true is returned.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator const char *
public:
virtual operator const char *() const

Returns the error text.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
text
public:
virtual const char* text() const

Returns the error text.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Throw Support

Use these members to support the throwing of exceptions.


[view class]
throwCLibError
public:
static void throwCLibError( const char* functionName, const IExceptionLocation& location, IBaseErrorInfo::ExceptionType name = accessError, IException::Severity severity = IException::recoverable )

Creates an ICLibErrorInfo object and uses the text from it to do the following:

  1. Create an exception object
  2. Add the location information to it
  3. Log the exception data
  4. Throw the exception
functionName
The name of the function where the exception occurred.
location
An IExceptionLocation object containing the following:
  • Function name
  • File name
  • Line number where the function is called
name
Use the enumeration IBaseErrorInfo::ExceptionType to specify the type of the exception. The default is accessError.
severity
Use the enumeration IException::Severity to specify the severity of the error. The default is recoverable.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


ICLibErrorInfo - Inherited Member Functions and Data

Inherited Public Functions

IBaseErrorInfo

Inherited Public Data

Inherited Protected Functions

Inherited Protected Data