aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/main.h1
-rw-r--r--g10/misc.c25
2 files changed, 26 insertions, 0 deletions
diff --git a/g10/main.h b/g10/main.h
index e9f557df0..e4c6e8fdd 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -89,6 +89,7 @@ void print_pubkey_algo_note (pubkey_algo_t algo);
void print_cipher_algo_note (cipher_algo_t algo);
void print_digest_algo_note (digest_algo_t algo);
void print_digest_rejected_note (enum gcry_md_algos algo);
+void print_reported_error (gpg_error_t err, gpg_err_code_t skip_if_ec);
void additional_weak_digest (const char* digestname);
/*-- armor.c --*/
diff --git a/g10/misc.c b/g10/misc.c
index 547944d34..57d5fef80 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -358,6 +358,31 @@ print_digest_rejected_note (enum gcry_md_algos algo)
}
+/* Print a message
+ * "(reported error: %s)\n
+ * in verbose mode to further explain an error. If the error code has
+ * the value IGNORE_EC no message is printed. A message is also not
+ * printed if ERR is 0. */
+void
+print_reported_error (gpg_error_t err, gpg_err_code_t ignore_ec)
+{
+ if (!opt.verbose)
+ return;
+
+ if (!gpg_err_code (err))
+ ;
+ else if (gpg_err_code (err) == ignore_ec)
+ ;
+ else if (gpg_err_source (err) == GPG_ERR_SOURCE_DEFAULT)
+ log_info (_("(reported error: %s\n)"),
+ gpg_strerror (err));
+ else
+ log_info (_("(reported error: %s <%s>\n)"),
+ gpg_strerror (err), gpg_strsource (err));
+
+}
+
+
/* Map OpenPGP algo numbers to those used by Libgcrypt. We need to do
this for algorithms we implemented in Libgcrypt after they become
part of OpenPGP. */