TAPs 0.7.7.3
TAPsException.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsException.cpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (03/26/2010)
00009 UPDATE          (04/15/2010)
00010 ******************************************************************************/
00011 #include "TAPsException.hpp"
00012 // Using Inclusion Model (i.e. definitions are included in declarations)
00013 //                       (this name.cpp is included in name.hpp)
00014 // Each friend is defined directly inside its declaration.
00015 
00016 BEGIN_NAMESPACE_TAPs
00017 //=============================================================================
00018 std::string Exception::g_Description[] = {
00019     "\"error found\"",
00020     "\"undefined exception\"",
00021     "\"file cannot be opened\"",
00022     "\"bad format\"",
00023     "\"cannot create an object\"",
00024 };
00025 //=============================================================================
00026 //-----------------------------------------------------------------------------
00027 Exception::Exception ( enum Type e, std::string const & fileName, int lineNumber, std::string const & massage ) throw()
00028 : m_Type( e )
00029 , Line( lineNumber )
00030 , File( fileName )
00031 , Message( massage )
00032 {}
00033 //-----------------------------------------------------------------------------
00034 Exception::Exception ( const Exception & E ) throw()
00035 : m_Type( E.m_Type )
00036 , Line( E.Line )
00037 , File( E.File )
00038 , Message( E.Message )
00039 {}
00040 //-----------------------------------------------------------------------------
00041 Exception & Exception::operator=( const Exception & E ) throw()
00042 {
00043     m_Type = E.m_Type;
00044     Line = E.Line;
00045     File = E.File;
00046     Message = E.Message;
00047     return *this;
00048 }
00049 //-----------------------------------------------------------------------------
00050 Exception::~Exception ()
00051 {}
00052 //-----------------------------------------------------------------------------
00053 const char * Exception::what () const throw()
00054 {
00055     std::stringstream ss;
00056     ss << "Exception: " << g_Description[m_Type] << " in file \"" << File << "\" at line# " << Line << "!\n";
00057     ss << " " << Message << "\n";
00058     return ss.str().c_str();
00059 }
00060 //-----------------------------------------------------------------------------
00061 std::string Exception::What () const throw()
00062 {
00063     std::stringstream ss;
00064     ss << "Exception: " << g_Description[m_Type] << " in file \"" << File << "\" at line# " << Line << "!\n";
00065     ss << " " << Message << "\n";
00066     return ss.str();
00067 }
00068 //-----------------------------------------------------------------------------
00069 void Exception::AddMessage ( std::string const & msg ) throw()
00070 {
00071     Message += msg;
00072 }
00073 //-----------------------------------------------------------------------------
00074 //=============================================================================
00075 END_NAMESPACE_TAPs
00076 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00077 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines