If an OS system call fails the error code reported by the OS needs to be saved for future reference. The OS error code as well as the corresponding portable error code are stored in the per thread buffers hyportptb.h via a call the hyerror_set_last_error or hyerror_set_last_error_with_message. These functions are meant for private use by the port library, to set the error related to a system call failure. They are in the port library table as people overriding port library functions may need to set the error message accordingly.
The majority of applications are not interested in the human readable error message corresponding to the error. As a result the error message is not stored at time of the reported error, but can be looked up at a later time.
#include <stdlib.h>
#include <string.h>
#include "portpriv.h"
#include "portnls.h"
#include "hyportptb.h"
Functions | |
I_32 VMCALL | hyerror_startup (struct HyPortLibrary *portLibrary) |
PortLibrary startup. | |
void VMCALL | hyerror_shutdown (struct HyPortLibrary *portLibrary) |
PortLibrary shutdown. | |
const char *VMCALL | hyerror_last_error_message (struct HyPortLibrary *portLibrary) |
Error Handling. | |
I_32 VMCALL | hyerror_last_error_number (struct HyPortLibrary *portLibrary) |
Error Handling. | |
I_32 VMCALL | hyerror_set_last_error (struct HyPortLibrary *portLibrary, I_32 platformCode, I_32 portableCode) |
Error Handling. | |
I_32 VMCALL | hyerror_set_last_error_with_message (struct HyPortLibrary *portLibrary, I_32 portableCode, const char *errorMessage) |
Error Handling. |
|
Error Handling. Return the error message as reported by the OS for the last saved error. If no error has been saved then an empty message is returned.
|
|
Error Handling. Look up the reason for the last stored failure. If no error code has been stored then failure is returned.
|
|
Error Handling. Save the platform specific error code and the portable error code for future reference. Once stored an application may obtain the error message describing the last stored error by calling hyerror_last_error_message. Likewise the last portable error code can be obtained by calling hyerror_last_error_number.
|
|
Error Handling. Save the platform specific error code and the portable error code for future reference. Once stored an application may obtain the error message describing the last stored error by calling hyerror_last_error_message. Likewise the last portable error code can be obtained by calling hyerror_last_error_number.
|
|
PortLibrary shutdown. This function is called during shutdown of the portLibrary. Any resources that were created by hyerror_startup should be destroyed here.
|
|
PortLibrary startup. This function is called during startup of the portLibrary. Any resources that are required for the error handling operations may be created here. All resources created here should be destroyed in hyerror_shutdown.
|