Commit 617846f2 authored by Steven Murray's avatar Steven Murray
Browse files

Improved the handling of comannd-line parse errors

parent eb4c08b5
......@@ -17,7 +17,7 @@
*/
#include "catalogue/CreateAdminHostCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -55,13 +55,13 @@ CreateAdminHostCmdLineArgs::CreateAdminHostCmdLineArgs(const int argc, char *con
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -71,7 +71,7 @@ CreateAdminHostCmdLineArgs::CreateAdminHostCmdLineArgs(const int argc, char *con
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -98,7 +98,7 @@ CreateAdminHostCmdLineArgs::CreateAdminHostCmdLineArgs(const int argc, char *con
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/CreateAdminHostCmd.hpp"
#include "catalogue/CreateAdminHostCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -17,7 +17,7 @@
*/
#include "catalogue/CreateAdminUserCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -55,13 +55,13 @@ CreateAdminUserCmdLineArgs::CreateAdminUserCmdLineArgs(const int argc, char *con
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -71,7 +71,7 @@ CreateAdminUserCmdLineArgs::CreateAdminUserCmdLineArgs(const int argc, char *con
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -98,7 +98,7 @@ CreateAdminUserCmdLineArgs::CreateAdminUserCmdLineArgs(const int argc, char *con
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/CreateAdminUserCmd.hpp"
#include "catalogue/CreateAdminUserCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -17,7 +17,7 @@
*/
#include "catalogue/CreateSchemaCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -48,13 +48,13 @@ CreateSchemaCmdLineArgs::CreateSchemaCmdLineArgs(const int argc, char *const *co
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -64,7 +64,7 @@ CreateSchemaCmdLineArgs::CreateSchemaCmdLineArgs(const int argc, char *const *co
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -83,7 +83,7 @@ CreateSchemaCmdLineArgs::CreateSchemaCmdLineArgs(const int argc, char *const *co
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/CreateSchemaCmd.hpp"
#include "catalogue/CreateSchemaCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -17,7 +17,7 @@
*/
#include "catalogue/DeleteAllCatalogueDataCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -48,13 +48,13 @@ DeleteAllCatalogueDataCmdLineArgs::DeleteAllCatalogueDataCmdLineArgs(const int a
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -64,7 +64,7 @@ DeleteAllCatalogueDataCmdLineArgs::DeleteAllCatalogueDataCmdLineArgs(const int a
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -83,7 +83,7 @@ DeleteAllCatalogueDataCmdLineArgs::DeleteAllCatalogueDataCmdLineArgs(const int a
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/DeleteAllCatalogueDataCmd.hpp"
#include "catalogue/DeleteAllCatalogueDataCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -17,7 +17,7 @@
*/
#include "catalogue/DropSchemaCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -48,13 +48,13 @@ DropSchemaCmdLineArgs::DropSchemaCmdLineArgs(const int argc, char *const *const
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -64,7 +64,7 @@ DropSchemaCmdLineArgs::DropSchemaCmdLineArgs(const int argc, char *const *const
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -83,7 +83,7 @@ DropSchemaCmdLineArgs::DropSchemaCmdLineArgs(const int argc, char *const *const
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/DropSchemaCmd.hpp"
#include "catalogue/DropSchemaCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -17,7 +17,7 @@
*/
#include "catalogue/LockSchemaCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -48,13 +48,13 @@ LockSchemaCmdLineArgs::LockSchemaCmdLineArgs(const int argc, char *const *const
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -64,7 +64,7 @@ LockSchemaCmdLineArgs::LockSchemaCmdLineArgs(const int argc, char *const *const
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -83,7 +83,7 @@ LockSchemaCmdLineArgs::LockSchemaCmdLineArgs(const int argc, char *const *const
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/LockSchemaCmd.hpp"
#include "catalogue/LockSchemaCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -18,7 +18,7 @@
#include "catalogue/PollDatabaseCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include "common/utils/utils.hpp"
#include <getopt.h>
......@@ -50,13 +50,13 @@ PollDatabaseCmdLineArgs::PollDatabaseCmdLineArgs(const int argc, char *const *co
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -66,7 +66,7 @@ PollDatabaseCmdLineArgs::PollDatabaseCmdLineArgs(const int argc, char *const *co
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -85,7 +85,7 @@ PollDatabaseCmdLineArgs::PollDatabaseCmdLineArgs(const int argc, char *const *co
// Check the number of arguments
if(nbArgs != 2) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/PollDatabaseCmd.hpp"
#include "catalogue/PollDatabaseCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -17,7 +17,7 @@
*/
#include "catalogue/SchemaStatusCmdLineArgs.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -48,13 +48,13 @@ SchemaStatusCmdLineArgs::SchemaStatusCmdLineArgs(const int argc, char *const *co
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -64,7 +64,7 @@ SchemaStatusCmdLineArgs::SchemaStatusCmdLineArgs(const int argc, char *const *co
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -83,7 +83,7 @@ SchemaStatusCmdLineArgs::SchemaStatusCmdLineArgs(const int argc, char *const *co
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/SchemaStatusCmd.hpp"
#include "catalogue/SchemaStatusCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
......@@ -18,7 +18,7 @@
#include "catalogue/UnlockSchemaCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <getopt.h>
#include <ostream>
......@@ -49,13 +49,13 @@ UnlockSchemaCmdLineArgs::UnlockSchemaCmdLineArgs(const int argc, char *const *co
break;
case ':': // Missing parameter
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
......@@ -65,7 +65,7 @@ UnlockSchemaCmdLineArgs::UnlockSchemaCmdLineArgs(const int argc, char *const *co
}
default:
{
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
......@@ -84,7 +84,7 @@ UnlockSchemaCmdLineArgs::UnlockSchemaCmdLineArgs(const int argc, char *const *co
// Check the number of arguments
if(nbArgs != 1) {
exception::UserError ex;
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=1 actual=" << (argc - 1);
throw ex;
}
......
......@@ -19,7 +19,7 @@
#include "catalogue/UnlockSchemaCmd.hpp"
#include "catalogue/UnlockSchemaCmdLineArgs.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <iostream>
......@@ -43,7 +43,7 @@ int main(const int argc, char *const *const argv) {
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::UserError &ue) {
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
userError = true;
} catch(exception::Exception &ex) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment