IBaseErrorInfo

The IBaseErrorInfo class is an abstract base class that defines the interface for its derived classes. These classes retrieve error information and text that you can subsequently use to create an exception object. The following macros assist in throwing exceptions:

IASSERTPARM
This macro accepts an expression to test. The expression is asserted to be true. If it evaluates to false, the macro generates code that calls the IExcept__assertParameter function, which creates an IInvalidParameter exception. The error group, other, is added to the object. The exception data is logged using IException::TraceFn::logExceptionData, and the exception is then thrown.
IASSERTSTATE
This macro accepts an expression to test. The expression is asserted to be true. If it evaluates to false, the macro generates code that calls the IExcept__assertState function, which creates an IInvalidRequest exception. The error group, other, is added to the object. The exception data is logged, and the exception is then thrown.
ITHROWLIBRARYERROR
This macro can throw any of the Open Class Library-defined exceptions.
id
The ID of the message to load from the class library message file.
name
A value from the enumeration IBaseErrorInfo::ExceptionType, indicating the type of exception to create.
severity
A value from the enumeration IException::Severity, indicating the severity of the exception.

The macro generates code that calls the IExcept__throwLibraryError function, which does the following:

  1. Loads the message text from the class library message file
  2. Uses the message text to create an exception object
  3. Adds location information
  4. Logs the exception data
  5. Throws the exception
ITHROWLIBRARYERROR1
This macro can throw any of the Open Class Library-defined exceptions. It is identical to the ITHROWLIBRARYERROR macro, except it has a fourth parameter:
text
Replacement text for the retrieved message.
ITHROWERROR
This macro can throw any of the Open Class Library-defined exceptions.
messageId
The ID of the message to load from the message file.
name
A value from the enumeration IBaseErrorInfo::ExceptionType, indicating the type of exception to create.
severity
A value from the enumeration IException::Severity, indicating the severity of the exception.
messageFile
The name of the message file to load the exception text from. This name should include the file extension, for exampl, usermsg.msg.
errorGroup
The errorGroup associated with this error. This can be one of the values for ErrorCodeGroup defined in IException or a value you provide.

The macro generates code that calls the IExcept__throwError function, which does the following:

  1. Loads the message text from the specified library message file
  2. Uses the message text to create an exception object
  3. Adds the error group to the object
  4. Adds location information
  5. Logs the exception data
  6. Throws the exception
ITHROWERROR1
This macro can throw any of the Open Class Library-defined exceptions. It is identical to the ITHROWERROR macro, except it has a fourth parameter:
substitutionText
Substitution text for the retrieved message.

AIX Considerations

IXLibErrorInfo is derived from this class. You can use IXLibErrorInfo to obtain error information about error conditions detected when calling X Library APIs. Use ICLibErrorInfo to obtain error information about error conditions detected when calling C Library functions.

You can create objects of IGUIErrorInfo and ISystemErrorInfo on AIX, but they have the following default messages:

IGUIErrorInfo
GUI exception condition detected
ISystemErrorInfo
System exception condition detected

OS/2 Considerations

IGUIErrorInfo, ISystemErrorInfo, and ICLibErrorInfo are derived from this class. You can use IGUIErrorInfo to obtain information about errors detected by the Win calls for Presentation Manager. Use ISystemErrorInfo to obtain error information about DOS system call errors.

Windows Considerations

In prior releases of Open Class Library, this class was named IErrorInfo, but Windows also uses the IErrorInfo class name. To assist in migrating your code to the new class name, add the -DIUSE_IERRORINFO keyword to your compiler flag definitions. This adds a typedef to your code so that IErrorInfo is defined as IBaseErrorInfo. Note that you cannot use this solution when your code also includes the Windows IErrorInfo class.


IBaseErrorInfo - Member Functions and Data by Group

Constructors & Destructor

This is a virtual base class so you cannot create objects of this type without deriving from this class.


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

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IBaseErrorInfo
public:
IBaseErrorInfo()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Error Information

Use these members to return error information provided by objects of this class. All the members are pure virtual.


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

Returns the error ID.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


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

If error information 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 = 0

Returns the error text.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


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

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]
throwError
public:
void throwError( const IExceptionLocation& location, ExceptionType name = accessError, IException::Severity severity = IException::recoverable, IException::ErrorCodeGroup errorGroup = IException::baseLibrary )

Creates an IBaseErrorInfo object and uses it to do the following:

  1. Create an exception object
  2. Add the error code group to the object
  3. Add the location information to the object
  4. Log the exception data
  5. Throw the exception
location
An IExceptionLocation object containing the following:
  • Function name
  • File name
  • Line number where the function is called
name
Use the enumeration 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.
errorGroup
Use one of the ErrorCodeGroup values provided in IException, or provide your own group for this parameter. The default is baseLibrary.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IBaseErrorInfo - Enumerations


[view class]
ExceptionType
enum ExceptionType { accessError, 
                     deviceError, 
                     invalidParameter, 
                     invalidRequest, 
                     outOfSystemResource, 
                     outOfWindowResource, 
                     outOfMemory, 
                     resourceExhausted }

The following enumeration type is defined to specify the type of exception to create on various functions and macros:

ExceptionType
Specifies the type of exception to be created. The allowable values are:
accessError
Creates an IAccessError object.
deviceError
Creates an IDeviceError object.
invalidParameter
Creates an IInvalidParameter object.
invalidRequest
Creates an IInvalidRequest object.
outOfSystemResource
Creates an IOutOfSystemResource object.
outOfWindowResource
Creates an IOutOfWindowResource object.
outOfMemory
Creates an IOutOfMemory object.
resourceExhausted
Creates an IResourceExhausted object.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IBaseErrorInfo - Inherited Member Functions and Data

Inherited Public Functions

Inherited Public Data

Inherited Protected Functions

Inherited Protected Data