r127 - branches/work_jls17

jls17 at arinside.org jls17 at arinside.org
Mon Feb 15 14:33:00 CST 2010


Author: jls17
Date: Mon Feb 15 14:32:59 2010
New Revision: 127
URL: http://arinside.org/changeset/127

Log:
added error check to ARSetServerPort; added special checks for required settings that can be specified in config file or at command line (finishes #60);

Modified:
   branches/work_jls17/ARInside.cpp
   branches/work_jls17/Main.cpp

Modified: branches/work_jls17/ARInside.cpp
==============================================================================
--- branches/work_jls17/ARInside.cpp	Sun Feb 14 15:10:41 2010	(r126)
+++ branches/work_jls17/ARInside.cpp	Mon Feb 15 14:32:59 2010	(r127)
@@ -137,6 +137,10 @@
 		if(port>0)
 		{
 			nResult = ARSetServerPort(&this->arControl, this->arControl.server, port, rpc, &this->arStatus);
+			if (nResult != AR_RETURN_OK)
+			{
+				throw(AppException(GetARStatusError(), "undefined", "ARSystem"));
+			}
 		}
 
 		if(nResult == AR_RETURN_OK)

Modified: branches/work_jls17/Main.cpp
==============================================================================
--- branches/work_jls17/Main.cpp	Sun Feb 14 15:10:41 2010	(r126)
+++ branches/work_jls17/Main.cpp	Mon Feb 15 14:32:59 2010	(r127)
@@ -89,15 +89,7 @@
 		rpc = rpcArg.getValue();
 		settingsIni = iniArg.getValue();
 		AppConfig::verboseMode = verboseArg.getValue();
-	} 
-	catch (ArgException &e)
-	{ 
-		cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
-		return AR_RETURN_ERROR;
-	}
 
-	try
-	{
 		std::ifstream in(settingsIni.c_str());		
 		if(!in)
 		{
@@ -129,6 +121,35 @@
 		if (rpc > 0)
 			appConfig.rpcPort = rpc;
 
+		// special checks for server mode
+		if (!appConfig.fileMode) 
+		{
+			string missingArgs;
+			unsigned int missingCount = 0;
+
+			if (appConfig.serverName.empty())
+			{
+				missingCount++;
+				missingArgs = "server / ServerName";
+			}
+			if (appConfig.userName.empty())
+			{
+				missingCount++;
+				if (!missingArgs.empty()) missingArgs += ", ";
+				missingArgs += "login / Username";
+			}
+
+			if (!missingArgs.empty())
+			{
+				string msg;
+				StdOutput _output;
+				msg = "Required argument(s) missing: " + missingArgs;
+				
+				cout << endl;
+				_output.failure(cmd,CmdLineParseException(msg));
+			}
+		}
+
 		CWindowsUtil winUtil(appConfig);		
 		CARInside arInside(appConfig);;
 
@@ -178,7 +199,7 @@
 					}
 					else
 					{
-						cout << "Couldt not find file '" << appConfig.objListXML << "'" << endl;
+						cout << "Could not find file '" << appConfig.objListXML << "'" << endl;
 						result = AR_RETURN_ERROR;
 					}
 				}
@@ -217,6 +238,15 @@
 	{
 		cout << endl << "AppException: " << e.typeDescription() << endl << "Description: " << e.error();	
 	}
+	catch (ArgException &e)
+	{ 
+		cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
+		return AR_RETURN_ERROR;
+	}
+	catch (ExitException &ee) 
+	{
+		exit(ee.getExitStatus());
+	}
 	catch(exception &e)
 	{
 		cout << endl << "Unhandled execption in _main: " << e.what() << endl;


More information about the arinside-src mailing list