[cig-commits] r12951 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Sep 24 04:10:39 PDT 2008


Author: luis
Date: 2008-09-24 04:10:39 -0700 (Wed, 24 Sep 2008)
New Revision: 12951

Added:
   cs/cigma/trunk/src/Exception.cpp
   cs/cigma/trunk/src/Exception.h
Log:
Base exception class

Added: cs/cigma/trunk/src/Exception.cpp
===================================================================
--- cs/cigma/trunk/src/Exception.cpp	                        (rev 0)
+++ cs/cigma/trunk/src/Exception.cpp	2008-09-24 11:10:39 UTC (rev 12951)
@@ -0,0 +1,19 @@
+#include "Exception.h"
+
+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() {}
+
+
+CmdException::CmdException() : Exception() {}
+CmdException::CmdException(const std::string &name, const std::string &message) : Exception(name,message) {}
+CmdException::~CmdException() {}
+
+
+

Added: cs/cigma/trunk/src/Exception.h
===================================================================
--- cs/cigma/trunk/src/Exception.h	                        (rev 0)
+++ cs/cigma/trunk/src/Exception.h	2008-09-24 11:10:39 UTC (rev 12951)
@@ -0,0 +1,42 @@
+#ifndef __CIGMA_EXCEPTION_H__
+#define __CIGMA_EXCEPTION_H__
+
+#include <string>
+
+namespace cigma
+{
+    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;
+
+        // Default constructor
+        Exception();
+
+        // copy constructor
+        Exception(const Exception &orig);
+
+        // virtual destructor
+        virtual ~Exception();
+
+    private:
+        std::string m_name;
+        std::string m_message;
+
+    protected:
+        static const std::string DEFAULT_MSG;
+    };
+
+    class CmdException : public Exception
+    {
+    public:
+        CmdException(const std::string &name, const std::string &message=DEFAULT_MSG);
+        CmdException();
+        virtual ~CmdException();
+    };
+}
+
+#endif



More information about the cig-commits mailing list