[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Error Handling

Many functions in FreeMD can return an error if they fail. For this reason, the application should always catch the error condition and take appropriate measures, for example by releasing the resources and passing the error up to the caller, or by displaying a descriptive message to the user and cancelling the operation.

Some error values do not indicate a system error or an error in the operation, but the result of an operation that failed properly. Such cases are described in the documentation of those functions.

3.1 Error Values  A list of all error values used.
3.2 Error Strings  How to get a descriptive string from a value.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Error Values

Data type: freemd_error_t
The freemd_error_t type specifies the set of all error values that are used by FreeMD. Possible values are:

This value indicates success. The value of this error is 0.

This value means that a call to the system library failed. The value of errno contains the system error value.

This value means that some user provided data was out of range.

This value is returned if some user provided data has a formatting error.

This value is returned if an unexpected error occurs in the communication with the Net MD device.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Error Strings

Function: const char * freemd_strerror (freemd_error_t err)
The function freemd_strerror returns a pointer to a statically allocated string containing a description of the error with the error value err. This string can be used to output a diagnostic message to the user.

The following example illustrates the use of freemd_strerror:

freemd_error_t err = freemd_init ();
if (err)
    fprintf (stderr, "%s: initializing FreeMD failed: %s\n",
             argv[0], freemd_strerror (err));
    exit (1);

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Marcus Brinkmann on January, 20 2003 using texi2html