Update of /cvsroot/pclasses/pclasses2/src/App
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16708/src/App
Modified Files:
CmdLine.cpp
Log Message:
- Removed std::string from Exception. The base exception should not throw in any case
- Fixed CmdLineError and added extra exception info field
Index: CmdLine.cpp
===================================================================
RCS file: /cvsroot/pclasses/pclasses2/src/App/CmdLine.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CmdLine.cpp 24 Jan 2005 22:58:42 -0000 1.6
+++ CmdLine.cpp 1 Jul 2005 13:52:51 -0000 1.7
@@ -164,12 +164,13 @@
return 0;
}
-CmdLineError::CmdLineError(const std::string& what, const SourceInfo& si)
-: RuntimeError(what, si)
+CmdLineError::CmdLineError(const char* what, const std::string& extra,
+ const SourceInfo& si)
+: RuntimeError(what, si), _extra(extra)
{
}
-CmdLineError::~CmdLineError()
+CmdLineError::~CmdLineError() throw()
{
}
@@ -221,8 +222,8 @@
// unknown option ...
if(!opt)
- throw CmdLineError("Unknown command-line argument: " +
- std::string(argv[i]), P_SOURCEINFO);
+ throw CmdLineError("Unknown command-line argument",
+ argv[i], P_SOURCEINFO);
// do we have value for this option ....?
// it doesnt matter if the option needs a value or not...
@@ -263,14 +264,13 @@
if(opt)
{
std::ostringstream errOs;
- errOs << "Value for command-line argument '";
- if(opt->shortName().size() > 0)
+ if(!opt->shortName().empty())
errOs << "-" << opt->shortName();
else
errOs << "--" << opt->longName();
- errOs << "' is missing." << std::endl;
- throw CmdLineError(errOs.str(), P_SOURCEINFO);
+ throw CmdLineError("Missing value for command-line argument",
+ errOs.str(), P_SOURCEINFO);
}
// search for required option which where not found
@@ -289,14 +289,13 @@
if(_opts[i]->required() && !_opts[i]->isset())
{
std::ostringstream errOs;
- errOs << "Required command-line argument '";
- if(_opts[i]->shortName().size() > 0)
+ if(!_opts[i]->shortName().empty())
errOs << "-" << _opts[i]->shortName();
else
errOs << "--" << _opts[i]->longName();
- errOs << "' missing." << std::endl;
- throw CmdLineError(errOs.str(), P_SOURCEINFO);
+ throw CmdLineError("Missing required command-line argument",
+ errOs.str(), P_SOURCEINFO);
}
}
@@ -321,7 +320,7 @@
void CmdLineParser::parse(const std::string& cmdline) throw(CmdLineError)
{
//@fixme
- throw CmdLineError("Not implemented", P_SOURCEINFO);
+ throw CmdLineError("Not implemented", "", P_SOURCEINFO);
}
void CmdLineParser::dumpHelp(std::ostream& os) const
|