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 @@ -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(std::stoul(fields[1]))}; + } else { + err = Error::fromCode(GPG_ERR_GENERAL); + } + + return err; +} + static const char *const status_strings[] = { "EOF", /* mkstatus processing starts here */ diff --git a/lang/cpp/src/editinteractor.h b/lang/cpp/src/editinteractor.h index 247bf8c0..2505b028 100644 --- a/lang/cpp/src/editinteractor.h +++ b/lang/cpp/src/editinteractor.h @@ -60,6 +60,9 @@ public: void setDebugChannel(std::FILE *file); +protected: + Error parseStatusError(const char *args); + private: class Private; Private *const d; diff --git a/lang/cpp/src/gpgrevokekeyeditinteractor.cpp b/lang/cpp/src/gpgrevokekeyeditinteractor.cpp index a90b5934..86b3c3c4 100644 --- a/lang/cpp/src/gpgrevokekeyeditinteractor.cpp +++ b/lang/cpp/src/gpgrevokekeyeditinteractor.cpp @@ -116,6 +116,10 @@ unsigned int GpgRevokeKeyEditInteractor::Private::nextState(unsigned int status, return q->state(); } + if (status == GPGME_STATUS_ERROR) { + err = q->parseStatusError(args); + return ERROR; + } switch (const auto state = q->state()) { case START: if (status == GPGME_STATUS_GET_LINE &&