libsigrok  0.3.0
sigrok hardware access and backend library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Error handling

Error handling in libsigrok. More...

Functions

const char * sr_strerror (int error_code)
 Return a human-readable error string for the given libsigrok error code. More...
 
const char * sr_strerror_name (int error_code)
 Return the "name" string of the given libsigrok error code. More...
 

Detailed Description

Error handling in libsigrok.

libsigrok functions usually return SR_OK upon success, or a negative error code on failure.

Function Documentation

const char* sr_strerror ( int  error_code)

Return a human-readable error string for the given libsigrok error code.

Parameters
error_codeA libsigrok error code number, such as SR_ERR_MALLOC.
Returns
A const string containing a short, human-readable (English) description of the error, such as "memory allocation error". The string must NOT be free'd by the caller!
See Also
sr_strerror_name
Since
0.2.0

Definition at line 53 of file error.c.

References SR_ERR, SR_ERR_ARG, SR_ERR_BUG, SR_ERR_CHANNEL_GROUP, SR_ERR_DEV_CLOSED, SR_ERR_MALLOC, SR_ERR_NA, SR_ERR_SAMPLERATE, SR_ERR_TIMEOUT, and SR_OK.

Referenced by sr_session_dev_add(), and sr_session_start().

+ Here is the caller graph for this function:

const char* sr_strerror_name ( int  error_code)

Return the "name" string of the given libsigrok error code.

For example, the "name" of the SR_ERR_MALLOC error code is "SR_ERR_MALLOC", the name of the SR_OK code is "SR_OK", and so on.

This function can be used for various purposes where the "name" string of a libsigrok error code is useful.

Parameters
error_codeA libsigrok error code number, such as SR_ERR_MALLOC.
Returns
A const string containing the "name" of the error code as string. The string must NOT be free'd by the caller!
See Also
sr_strerror
Since
0.2.0

Definition at line 104 of file error.c.

References SR_ERR, SR_ERR_ARG, SR_ERR_BUG, SR_ERR_CHANNEL_GROUP, SR_ERR_DEV_CLOSED, SR_ERR_MALLOC, SR_ERR_NA, SR_ERR_SAMPLERATE, SR_ERR_TIMEOUT, and SR_OK.