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. |
const char* VMCALL hyerror_last_error_message | ( | struct HyPortLibrary * | portLibrary | ) |
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.
[in] | portLibrary | The port library |
I_32 VMCALL hyerror_last_error_number | ( | struct HyPortLibrary * | portLibrary | ) |
Error Handling.
Look up the reason for the last stored failure. If no error code has been stored then failure is returned.
[in] | portLibrary | The port library |
I_32 VMCALL hyerror_set_last_error | ( | struct HyPortLibrary * | portLibrary, | |
I_32 | platformCode, | |||
I_32 | portableCode | |||
) |
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.
[in] | portLibrary | The port library |
[in] | platformCode | The error code reported by the OS |
[in] | portableCode | The corresponding portable error code as determined by the caller |
If per thread buffers
I_32 VMCALL hyerror_set_last_error_with_message | ( | struct HyPortLibrary * | portLibrary, | |
I_32 | portableCode, | |||
const char * | errorMessage | |||
) |
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.
[in] | portLibrary | The port library |
[in] | portableCode | The corresponding portable error code as determined by the caller |
[in] | errorMessage | The customized error message to be stored |
If per thread buffers
void VMCALL hyerror_shutdown | ( | struct HyPortLibrary * | portLibrary | ) |
PortLibrary shutdown.
This function is called during shutdown of the portLibrary. Any resources that were created by hyerror_startup should be destroyed here.
[in] | portLibrary | The port library |
I_32 VMCALL hyerror_startup | ( | struct HyPortLibrary * | portLibrary | ) |
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.
[in] | portLibrary | The port library |
Genereated on Tue Dec 9 14:12:59 2008 by Doxygen.
(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.