changeset 98:6090e673c707

Add some error handling. Change process path for testing
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 21 Mar 2014 10:50:01 +0000
parents e478deca18f5
children bc1e6732f43c
files ui/listupdatedialog.cpp
diffstat 1 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ui/listupdatedialog.cpp	Fri Mar 21 10:42:29 2014 +0000
+++ b/ui/listupdatedialog.cpp	Fri Mar 21 10:50:01 2014 +0000
@@ -81,9 +81,14 @@
     /* TODO move this in another dialog and call it async*/
     QProcess installerProcess;
 
-    installerProcess.setProgram("cinst");
+    installerProcess.setProgram("../cinst/cinst");
     installerProcess.start();
     installerProcess.waitForStarted();
+    if (installerProcess.state() == QProcess::NotRunning) {
+        qWarning() << "Failed to start installer Process.";
+        /* TODO ERROR message for the user */
+        return;
+    }
     installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n");
     installerProcess.write(mCertificateList.rawData().toLatin1());
     installerProcess.write("-----END CERTIFICATE LIST-----\r\n");
@@ -98,7 +103,23 @@
 
     installerProcess.closeWriteChannel();
     installerProcess.waitForFinished();
-    qDebug() << "cinst output: " << installerProcess.readAllStandardOutput();
-    qDebug() << " Done " << " exitCode: " << installerProcess.exitCode();
-    qDebug() << " Done " << " exitStatus: " << installerProcess.exitStatus();
+
+    if (installerProcess.exitStatus() == QProcess::CrashExit) {
+        /* Woops */
+        qWarning() << "Installer process crashed";
+    } else if (installerProcess.exitStatus() != QProcess::NormalExit) {
+        /* Can not Happen. there are only those two values but maybe
+         * qt changed.. */
+        qWarning() << "Exit status neither normal nor crash.";
+        return;
+    }
+
+    if (installerProcess.exitCode() == 0) {
+        qDebug() << "Success!";
+    } else {
+        /* TODO handle errors defined by errorcodes.h */
+        qDebug() << "Installer Process returned: " << installerProcess.exitCode();
+        qDebug() << "output: " << installerProcess.readAllStandardOutput();
+        return;
+    }
 }

http://wald.intevation.org/projects/trustbridge/