Os error

From Java4c

Contents

[edit] Navigation

[edit] Overview

Generally an error handling is necessary to detect failures in the software. In a situation where a function doesn't know what to do

  • either it should return with an message error
  • or it should call an error routine
  • or it should throw an exception.

In the first case the user should be check the return state and handle with the error, whereby in the last two cases the user should not know anything about possible errors in its best case programming branch. Therefore a try-catch-throw mechanism is established for high level user programming. But in the OSAL layer usual a return value is used to detect the error state. It is so, because any try-catch mechanism is defined in a layer above the OSALs one only.

Nevertheless it is advisable to support an error handling adequate to try-throw at OSAL-level too.

[edit] Error handling in OSAL

The OSAL in the CRuntimeJavalike environment supports the following mechanism:

[edit] Error routine to user level support

A function type

C_TYPE typedef void MT_os_Error(int errorCode, const char* description, int value1, int value2);

is defined. The routine

extern_C int os_setErrorRoutine(MT_os_Error* routine);

accepts any routine with this prototype. Using this mechanism any error at OSAL level can be transferred to a higher user level, for example to use a throw mechanism in a try-catch environment or to support an error logging.

All conflicts in the OSAL adaption routines with the operation system or with itself should call the routine ...TODO

Personal tools