Ver Fonte

Some improvements to helper error replies

Malte Veerman há 6 anos atrás
pai
commit
07943b637b

+ 10 - 0
helper/src/helper.cpp

@@ -98,6 +98,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
             {
                 if (dbusmessage.type() == QDBusMessage::ErrorMessage)
                 {
+                    reply = ActionReply::HelperErrorReply();
                     reply.setErrorCode(ActionReply::DBusError);
                     reply.setErrorDescription(dbusmessage.errorMessage());
                 }
@@ -117,6 +118,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
                         else
                         {
                             reply = ActionReply::HelperErrorReply();
+                            reply.setErrorCode(ActionReply::DBusError);
                             reply.setErrorDescription(dbusreply.error().message());
                         }
                     }
@@ -136,6 +138,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
                         else
                         {
                             reply = ActionReply::HelperErrorReply();
+                            reply.setErrorCode(ActionReply::DBusError);
                             reply.setErrorDescription(dbusreply.error().message());
                         }
                     }
@@ -151,6 +154,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
                         else
                         {
                             reply = ActionReply::HelperErrorReply();
+                            reply.setErrorCode(ActionReply::DBusError);
                             reply.setErrorDescription(dbusreply.error().message());
                         }
                     }
@@ -160,6 +164,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
         else
         {
             reply = ActionReply::HelperErrorReply();
+            reply.setErrorCode(ActionReply::DBusError);
             reply.setErrorDescription(i18n("Could not create dbus interface"));
         }
         delete iface;
@@ -181,6 +186,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
         else
         {
             reply = ActionReply::HelperErrorReply();
+            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(file.errorString());
         }
     }
@@ -198,6 +204,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
         else
         {
             reply = ActionReply::HelperErrorReply();
+            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(file.errorString());
         }
     }
@@ -213,11 +220,13 @@ ActionReply Helper::action(const QVariantMap &arguments)
         if (!process.waitForStarted(1000))
         {
             reply = ActionReply::HelperErrorReply();
+            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(process.errorString());
         }
         else if (!process.waitForFinished(10000))
         {
             reply = ActionReply::HelperErrorReply();
+            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(process.errorString());
         }
     }
@@ -225,6 +234,7 @@ ActionReply Helper::action(const QVariantMap &arguments)
     else
     {
         reply = ActionReply::HelperErrorReply();
+        reply.setErrorCode(ActionReply::NoSuchActionError);
         reply.setErrorDescription(i18n("This action does not exist!"));
     }
 

+ 0 - 3
import/src/guibase.cpp

@@ -358,10 +358,7 @@ void GUIBase::deleteProfile(int index, bool updateModel)
     auto profiles = Config::instance()->findItem(QStringLiteral("Profiles"))->property().toStringList();
 
     if (index < 0 || index >= profileNames.size() || index >= profiles.size())
-    {
-        qDebug() << "Index out of bounds";
         return;
-    }
 
     profileNames.removeAt(index);
     Config::instance()->findItem(QStringLiteral("ProfileNames"))->setProperty(profileNames);

+ 1 - 1
import/src/loader.cpp

@@ -455,7 +455,7 @@ bool Loader::load(const QUrl &url)
                     return false;
                 }
 
-                emit error(i18n("KAuth::ExecuteJob error! Code: %1\nAdditional Info: %2; %3", job->error(), job->errorString(), job->errorText()), true);
+                emit error(i18n("KAuth::ExecuteJob error! Code: %1\nAdditional Info: %2", job->error(), job->errorString()), true);
                 return false;
             }
             else

+ 1 - 1
import/src/systemdcommunicator.cpp

@@ -284,7 +284,7 @@ bool SystemdCommunicator::dbusAction(const QString &method, const QVariantList &
         }
     }
     else
-        emit error(i18n("KAuth::ExecuteJob error! Code: %1\nAdditional Info: %2; %3", job->error(), job->errorString(), job->errorText()), true);
+        emit error(i18n("KAuth::ExecuteJob error! Code: %1\nAdditional Info: %2", job->error(), job->errorString()), true);
 
     return success;
 }