php8.5
Home/ Manual/ gnupg / functions/ gnupg_geterrorinfo

gnupg_geterrorinfo

PHP function Edit on GitHub ✎

(PECL gnupg >= 1.5)

Returns the error info

Description

gnupg_geterrorinfo(resource $identifier): array

Parameters

identifier

Identifier

Return Values

Returns an array with error info.

Examples

Procedural gnupg_geterrorinfo() example

php
<?php
$res = gnupg_init();
// this is called without any error
print_r(gnupg_geterrorinfo($res));
?>

The above example will output:

output
array(4) {
  ["generic_message"]=>
  bool(false)
  ["gpgme_code"]=>
  int(0)
  ["gpgme_source"]=>
  string(18) "Unspecified source"
  ["gpgme_message"]=>
  string(7) "Success"
}

OO gnupg_geterrorinfo() example

php
<?php
$gpg = new gnupg();
// error call
$gpg->decrypt('abc');
// error info should be displayed
print_r($gpg->geterrorinfo());
?>

The above example will output:

output
array(4) {
  ["generic_message"]=>
  string(14) "decrypt failed"
  ["gpgme_code"]=>
  int(117440570)
  ["gpgme_source"]=>
  string(5) "GPGME"
  ["gpgme_message"]=>
  string(7) "No data"
}

Source: reference/gnupg/functions/gnupg-geterrorinfo.xml · from the official PHP manual (php/doc-en)