/[escript]/trunk/esysUtils/src/EsysAssertException.h
ViewVC logotype

Diff of /trunk/esysUtils/src/EsysAssertException.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1454 by trankine, Fri Jan 11 07:45:58 2008 UTC revision 1455 by phornby, Thu Feb 28 17:19:44 2008 UTC
# Line 19  Line 19 
19    
20  #include "EsysException.h"  #include "EsysException.h"
21    
 #include <string>  
 #include <sstream>  
   
22  namespace esysUtils {  namespace esysUtils {
23    
 /**  
    \brief  
    EsysAssertException exception class.  
   
    Description:  
    EsysAssertException exception class.  
    The class provides a public function returning the exception name.  
 */  
 class EsysAssertException:public EsysException {  
   
  public:  
   
24    /**    /**
25       \brief    \brief
26       Default constructor for the exception.    EsysAssertException exception class.
   */  
   EsysAssertException() : EsysException() {}  
27    
28    /**    Description:
29       \brief    EsysAssertException exception class.
30       Constructor for the exception.    The class provides a public function returning the exception name.
31    */    */
32    EsysAssertException(const char *cstr) : EsysException(cstr) {}    class EsysAssertException : public EsysException
33      {
   /**  
      \brief  
      Constructor for the exception.  
   */  
   EsysAssertException(const std::string &str) : EsysException(str) {}  
   
   /// Destructor  
   virtual ~EsysAssertException() throw() {}  
34    
35    /**    protected:
      \brief  
      Returns the name of the exception.  
   */  
   virtual std::string exceptionName() const {return "EsysAssertException";}  
36    
37    /**       typedef EsysException Parent;
      \brief  
      Builds a formatted message and throws an EsysAssertException.  
   */  
   static void assertFailure (const std::string& assertion,  
                  const std::string& date, const std::string& file,  
                  int line, const std::string& errDesc)  
   {  
    std::stringstream message;  
   
    message << std::endl  
            << "EsysAssert(" << assertion << ") failed with message - " << std::endl  
            << "\"" << errDesc << "\"" << std::endl  
            << "Assertion is located in File : " << file  
            << " at Line: " << line << std::endl  
            << "File Compilation Date: " << date << std::endl;  
   
    throw EsysAssertException(message.str());  
   }  
38    
39  };    public:
40        /**
41        \brief
42        Default constructor for the exception.
43        */
44        EsysAssertException() : Parent() { updateMessage();}
45        /**
46        \brief
47        Constructor for the exception.
48        */
49        EsysAssertException(const char *cstr) : Parent(cstr) { updateMessage();}
50        /**
51        \brief
52        Constructor for the exception.
53        */
54        EsysAssertException(const std::string &str) :
55        Parent(str) { updateMessage();}
56        /**
57        \brief
58        Copy Constructor for the exception.
59        */
60        EsysAssertException(const EsysAssertException &other) : Parent(other)
61          {
62            updateMessage();
63          }
64    
65    
66        /// Destructor
67        virtual ~EsysAssertException() THROW() {}
68    
69        /**
70        \brief
71        Returns the name of the exception.
72        */
73        virtual const std::string & exceptionName() const;
74    
75        /**
76        \brief
77        Builds a formatted message and throws an EsysAssertException.
78        */
79        static void assertFailure (const std::string& assertion,
80                                   const std::string& date,
81                                   const std::string& file,
82                                   int line, const std::string& errDesc);
83      private:
84    
85        //
86        // the exception name is immutable and class-wide.
87        // Inheritor note; you need one of these too.
88        // and an overloaded exceptionName() in your .cpp implementation file.
89        static const std::string exceptionNameValue;
90      };
91    
92  } // end of namespace  } // end of namespace
93    

Legend:
Removed from v.1454  
changed lines
  Added in v.1455

  ViewVC Help
Powered by ViewVC 1.1.26