Next: , Previous: , Up: Main Menu   [Contents][Index]

5 Error Handling

Many functions in GPGME 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. For example, if you try to decrypt a tempered message, the decryption will fail. Another error value actually means that the end of a data buffer or list has been reached. The following descriptions explain for many error codes what they mean usually. Some error values have specific meanings if returned by a certain functions. Such cases are described in the documentation of those functions.

GPGME uses the libgpg-error library. This allows to share the error codes with other components of the GnuPG system, and thus pass error values transparently from the crypto engine, or some helper application of the crypto engine, to the user. This way no information is lost. As a consequence, GPGME does not use its own identifiers for error codes, but uses those provided by libgpg-error. They usually start with GPG_ERR_.

However, GPGME does provide aliases for the functions defined in libgpg-error, which might be preferred for name space consistency.