Branch 'formatchecker' - utils/kolabformatchecker.cpp

Sofia Balicka balicka at kolabsys.com
Mon Dec 3 13:57:06 CET 2012


 utils/kolabformatchecker.cpp |   28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

New commits:
commit c78c8e316668d51b1135ea2ee4e937496a6560f2
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Mon Dec 3 13:56:17 2012 +0100

    Changed error handling.

diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
index af5a0ed..b28c4a0 100644
--- a/utils/kolabformatchecker.cpp
+++ b/utils/kolabformatchecker.cpp
@@ -44,37 +44,41 @@ int main(int argc, char *argv[])
 	
 	ErrorHandler::handleLibkolabxmlErrors();
 
-	bool faildToOpen=false;
-		
+	int returnValue = 0;
+
 	cout << endl;
 
 	for(vector<string>::const_iterator it = inputFiles.begin();
             it != inputFiles.end(); it++){
 
+		ErrorHandler::clearErrors();
+
 		cout << "File: " << *it << endl;
 
 		bool ok;
 		KMime::Message::Ptr message = readMimeFile( QString::fromStdString(*it), ok);
 
 		if(!ok){
-			faildToOpen=true;
+			returnValue = -1;
 			cout << endl;
 			continue;
 		}
 
 		Kolab::KolabObjectReader reader(message);
 	
-		if (!error()) {
-            cout << "Parsed message without error." << endl;
-        }
-		
+		if (error()){
+			cout << "Error: " << errorMessage() << endl;
+			returnValue = -1;
+		} else if (ErrorHandler::errorOccured()){
+			cout << "Errors occured during parsing." << endl;
+			returnValue = -1;
+		} else {
+			cout << "Parsed message without error." << endl;
+		}
+
 		cout << endl;
     }
 
-	if (ErrorHandler::errorOccured() || faildToOpen){
-		return -1;
-	}
-
-    return 0;
+    return returnValue;
 }
 





More information about the commits mailing list