[cig-commits] r13532 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:13:29 PST 2008
Author: luis
Date: 2008-12-09 18:13:29 -0800 (Tue, 09 Dec 2008)
New Revision: 13532
Modified:
cs/cigma/trunk/src/DataPath.cpp
cs/cigma/trunk/src/Exception.cpp
cs/cigma/trunk/src/Exception.h
cs/cigma/trunk/src/cli_application.cpp
Log:
Updated cigma::Exception with error code
Modified: cs/cigma/trunk/src/DataPath.cpp
===================================================================
--- cs/cigma/trunk/src/DataPath.cpp 2008-12-10 02:13:27 UTC (rev 13531)
+++ cs/cigma/trunk/src/DataPath.cpp 2008-12-10 02:13:29 UTC (rev 13532)
@@ -41,7 +41,7 @@
}
else
{
- throw cigma::Exception(string("DataPath"), string("Too many colons in path"));
+ throw cigma::Exception("DataPath", "Too many colons in path");
}
}
else
Modified: cs/cigma/trunk/src/Exception.cpp
===================================================================
--- cs/cigma/trunk/src/Exception.cpp 2008-12-10 02:13:27 UTC (rev 13531)
+++ cs/cigma/trunk/src/Exception.cpp 2008-12-10 02:13:29 UTC (rev 13532)
@@ -3,17 +3,56 @@
using namespace cigma;
const std::string Exception::DEFAULT_MSG("No detailed information provided");
-Exception::Exception() : m_name(""), m_message("") {}
-Exception::Exception(const std::string &name, const std::string &message) : m_name(name), m_message(message) {}
-Exception::Exception(const Exception &orig) { m_message = orig.m_message; m_name = orig.m_name; }
-std::string Exception::getName() const { return m_name; }
-std::string Exception::getMessage() const { return m_message; }
-Exception::~Exception() {}
+Exception::Exception() : m_name(""), m_message(""), m_code(0)
+{
+}
-CmdException::CmdException() : Exception() {}
-CmdException::CmdException(const std::string &name, const std::string &message) : Exception(name,message) {}
-CmdException::~CmdException() {}
+Exception::Exception(const std::string &name,
+ const std::string &message,
+ int code)
+ : m_name(name), m_message(message), m_code(code)
+{
+}
+Exception::Exception(const Exception &orig)
+{
+ m_name = orig.m_name;
+ m_message = orig.m_message;
+ m_code = orig.m_code;
+}
+std::string Exception::getName() const
+{
+ return m_name;
+}
+std::string Exception::getMessage() const
+{
+ return m_message;
+}
+
+int Exception::getCode() const
+{
+ return m_code;
+}
+
+Exception::~Exception()
+{
+}
+
+// ----------------------------------------------------------------------------
+
+CmdException::CmdException() : Exception()
+{
+}
+
+CmdException::CmdException(const std::string &name, const std::string &message) : Exception(name,message)
+{
+}
+
+CmdException::~CmdException()
+{
+}
+
+// ----------------------------------------------------------------------------
Modified: cs/cigma/trunk/src/Exception.h
===================================================================
--- cs/cigma/trunk/src/Exception.h 2008-12-10 02:13:27 UTC (rev 13531)
+++ cs/cigma/trunk/src/Exception.h 2008-12-10 02:13:29 UTC (rev 13532)
@@ -8,10 +8,8 @@
class Exception
{
public:
- // Creates an exception with a name and a detailed message.
- Exception(const std::string &name, const std::string &message=DEFAULT_MSG);
- std::string getMessage() const;
- std::string getName() const;
+ // Creates an exception with a name, detailed message, and optional error code
+ Exception(const std::string &name, const std::string &message=DEFAULT_MSG, int code=0);
// Default constructor
Exception();
@@ -22,9 +20,15 @@
// virtual destructor
virtual ~Exception();
+ // Accessors
+ std::string getName() const;
+ std::string getMessage() const;
+ int getCode() const;
+
private:
std::string m_name;
std::string m_message;
+ int m_code;
protected:
static const std::string DEFAULT_MSG;
Modified: cs/cigma/trunk/src/cli_application.cpp
===================================================================
--- cs/cigma/trunk/src/cli_application.cpp 2008-12-10 02:13:27 UTC (rev 13531)
+++ cs/cigma/trunk/src/cli_application.cpp 2008-12-10 02:13:29 UTC (rev 13532)
@@ -251,7 +251,14 @@
catch (cigma::Exception &e)
{
string msg = boost::algorithm::trim_copy(e.getMessage());
- cout << "cigma: " << msg << " (in " << e.getName() << ")" << endl;
+ int err = e.getCode();
+ cout << "cigma: ";
+ cout << msg;
+ if (err == 0)
+ {
+ cout << " (" << e.getName() << ")";
+ }
+ cout << endl;
return -1;
}
catch (bad_cast &e)
@@ -264,11 +271,13 @@
cout << "cigma: " << e.what() << endl;
return -1;
}
+ /*
catch (...)
{
cout << "cigma: Unrecognized exception!" << endl;
return -1;
}
+ */
return 0;
}
More information about the CIG-COMMITS
mailing list