File: gpgme.info, Node: Error Strings, Prev: Error Codes, Up: Error Handling 5.4 Error Strings ================= -- Function: const char * gpgme_strerror (gpgme_error_t ERR) The function ‘gpgme_strerror’ returns a pointer to a statically allocated string containing a description of the error code contained in the error value ERR. This string can be used to output a diagnostic message to the user. This function is not thread safe. Use ‘gpgme_strerror_r’ in multi-threaded programs. -- Function: int gpgme_strerror_r (gpgme_error_t ERR, char *BUF, size_t BUFLEN) The function ‘gpgme_strerror_r’ returns the error string for ERR in the user-supplied buffer BUF of size BUFLEN. This function is, in contrast to ‘gpgme_strerror’, thread-safe if a thread-safe ‘strerror_r’ function is provided by the system. If the function succeeds, 0 is returned and BUF contains the string describing the error. If the buffer was not large enough, ERANGE is returned and BUF contains as much of the beginning of the error string as fits into the buffer. -- Function: const char * gpgme_strsource (gpgme_error_t ERR) The function ‘gpgme_strerror’ returns a pointer to a statically allocated string containing a description of the error source contained in the error value ERR. This string can be used to output a diagnostic message to the user. The following example illustrates the use of ‘gpgme_strerror’: gpgme_ctx_t ctx; gpgme_error_t err = gpgme_new (&ctx); if (err) { fprintf (stderr, "%s: creating GpgME context failed: %s: %s\n", argv[0], gpgme_strsource (err), gpgme_strerror (err)); exit (1); }