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:
- Loads the message text from the class library message file
- Uses the message text to create an exception object
- Adds location information
- Logs the exception data
- 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:
- Loads the message text from the specified library message file
- Uses the message text to create an exception object
- Adds the error group to the object
- Adds location information
- Logs the exception data
- 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.
- ~IBaseErrorInfo
public:
virtual ~IBaseErrorInfo()
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- 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.
- errorId
public:
virtual unsigned long errorId() const = 0
Returns the error ID.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- isAvailable
public:
virtual bool isAvailable() const = 0
If error information is available, true is returned.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator const char *
public:
virtual operator const char *() const = 0
Returns the error text.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- 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.
- 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:
- Create an exception object
- Add the error code group to the object
- Add the location information to the object
- Log the exception data
- 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 |
- 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