diff options
author | Saturn&Eric <[email protected]> | 2022-05-20 19:13:55 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2022-05-20 19:13:55 +0000 |
commit | 306cc5b41af9596875c2999af638eaa35899e404 (patch) | |
tree | 6d8d5b3cdb35e79527d33c63d4e69995f9c3f2df /src/core/GpgConstants.cpp | |
parent | Merge pull request #65 from saturneric/develop-2.0.8 (diff) | |
parent | fix(ui): there is possible null pointer dereference (diff) | |
download | GpgFrontend-306cc5b41af9596875c2999af638eaa35899e404.tar.gz GpgFrontend-306cc5b41af9596875c2999af638eaa35899e404.zip |
Merge pull request #66 from saturneric/develop-2.0.8
Develop 2.0.8.2
Diffstat (limited to '')
-rw-r--r-- | src/core/GpgConstants.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/core/GpgConstants.cpp b/src/core/GpgConstants.cpp index 88068f37..ff783872 100644 --- a/src/core/GpgConstants.cpp +++ b/src/core/GpgConstants.cpp @@ -28,10 +28,7 @@ #include "core/GpgConstants.h" -#include <gpg-error.h> - #include <boost/algorithm/string/predicate.hpp> -#include <string> #include "function/FileOperator.h" @@ -56,9 +53,9 @@ const char* GpgFrontend::GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD = gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err) { if (gpg_err_code(err) != GPG_ERR_NO_ERROR) { - LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] " - << _("Source: ") << gpgme_strsource(err) << " " - << _("Description: ") << gpgme_strerror(err); + LOG(ERROR) << "[" << _("Error") << gpg_err_code(err) << "]" << _("Source: ") + << gpgme_strsource(err) << _("Description: ") + << gpgme_strerror(err); } return err; } @@ -66,10 +63,16 @@ gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err) { gpg_err_code_t GpgFrontend::check_gpg_error_2_err_code(gpgme_error_t err, gpgme_error_t predict) { auto err_code = gpg_err_code(err); - if (err_code != predict) { - LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] " - << _("Source: ") << gpgme_strsource(err) << " " - << _("Description: ") << gpgme_strerror(err); + if (err_code != gpg_err_code(predict)) { + if (err_code == GPG_ERR_NO_ERROR) + LOG(WARNING) << "[" << _("Warning") << gpg_err_code(err) << "]" + << _("Source: ") << gpgme_strsource(err) + << _("Description: ") << gpgme_strerror(err) << _("Predict") + << gpgme_strerror(err); + else + LOG(ERROR) << "[" << _("Error") << gpg_err_code(err) << "]" + << _("Source: ") << gpgme_strsource(err) << _("Description: ") + << gpgme_strerror(err) << _("Predict") << gpgme_strerror(err); } return err_code; } @@ -77,9 +80,9 @@ gpg_err_code_t GpgFrontend::check_gpg_error_2_err_code(gpgme_error_t err, gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err, const std::string& comment) { if (gpg_err_code(err) != GPG_ERR_NO_ERROR) { - LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] " - << _("Source: ") << gpgme_strsource(err) << " " - << _("Description: ") << gpgme_strerror(err); + LOG(ERROR) << "[" << _("Error") << gpg_err_code(err) << "]" << _("Source: ") + << gpgme_strsource(err) << _("Description: ") + << gpgme_strerror(err); } return err; } |