Voice API Programming Guide — June 2005 29
5
5.Error Handling
This chapter discusses how to handle errors that can occur when running an application.
All voice library functions return a value to indicate success or failure of the function. A return
value of zero or a non-negative number indicates success. A return value of -1 indicates failure.
If a voice library function fails, call the standard attribute functions ATDV_LASTERR( ) and
ATDV_ERRMSGP( ) to determine the reason for failure. For more information on these
functions, see the Standard Runtime Library API Library Reference.
If an extended attribute function fails, two types of errors can be generated. An extended attribute
function that returns a pointer will produce a pointer to the ASCIIZ string “Unknown device” if it
fails. An extended attribute function that does not return a pointer will produce a value of
AT_FAILURE if it fails. Extended attribute functions for the voice library are prefaced with
“ATDX_”.
Notes: 1. The dx_open( ) and dx_close( ) functions are exceptions to the above error handling rules. On
Linux, if these functions fail, the return code is -1, and the specific error is found in the errno
variable contained in errno.h. On Windows, if these functions fail, the return code is -1. Use
dx_fileerrno() to obtain the system error value.
2. If ATDV_LASTERR( ) returns the EDX_SYSTEM error code, an operating system error has
occurred. On Linux, check the global variable errno contained in errno.h. On Windows, use
dx_fileerrno() to obtain the system error value.
For a list of errors that can be returned by a voice library function, see the Voice API Library
Reference. You can also look up the error codes in the dxxxlib.h file.