diff options
author | Ingo Klöcker <[email protected]> | 2022-04-04 11:15:37 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2022-04-05 08:15:07 +0000 |
commit | db532eca8ebd64536985e7a40af22e803e3b3df9 (patch) | |
tree | 5354bbae8780d6f831c3b54f3a5760e8f2e832b6 /lang/cpp/src/editinteractor.cpp | |
parent | cpp: Add internal utility function for splitting strings (diff) | |
download | gpgme-db532eca8ebd64536985e7a40af22e803e3b3df9.tar.gz gpgme-db532eca8ebd64536985e7a40af22e803e3b3df9.zip |
cpp: Return actual error if revocation fails
* lang/cpp/src/editinteractor.cpp, lang/cpp/src/editinteractor.h
(EditInteractor::parseStatusError): New.
* lang/cpp/src/gpgrevokekeyeditinteractor.cpp
(GpgRevokeKeyEditInteractor::Private::nextState): Handle status
error.
--
With this change the interactor returns a proper error like "Bad
Passphrase" or "Empty Passphrase" instead of an unspecific "General
Error" if a status error occurred.
GnuPG-bug-id: 5904
Diffstat (limited to 'lang/cpp/src/editinteractor.cpp')
-rw-r--r-- | lang/cpp/src/editinteractor.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lang/cpp/src/editinteractor.cpp b/lang/cpp/src/editinteractor.cpp index e411adac..753c2b09 100644 --- a/lang/cpp/src/editinteractor.cpp +++ b/lang/cpp/src/editinteractor.cpp @@ -29,6 +29,7 @@ #include "editinteractor.h" #include "callbacks.h" #include "error.h" +#include "util.h" #include <gpgme.h> @@ -256,6 +257,20 @@ void EditInteractor::setDebugChannel(std::FILE *debug) d->debug = debug; } +GpgME::Error EditInteractor::parseStatusError(const char *args) +{ + Error err; + + const auto fields = split(args, ' '); + if (fields.size() >= 2) { + err = Error{static_cast<unsigned int>(std::stoul(fields[1]))}; + } else { + err = Error::fromCode(GPG_ERR_GENERAL); + } + + return err; +} + static const char *const status_strings[] = { "EOF", /* mkstatus processing starts here */ |