|
// $Id$ |
|
1 |
/* |
/* |
2 |
***************************************************************************** |
***************************************************************************** |
3 |
* * |
* * |
12 |
***************************************************************************** |
***************************************************************************** |
13 |
*/ |
*/ |
14 |
|
|
15 |
#if !defined escript_EsysAssertException_20040330_H |
#if !defined escript_EsysAssertException_20040330_H |
16 |
#define escript_EsysAssertException_20040330_H |
#define escript_EsysAssertException_20040330_H |
17 |
|
|
18 |
#include "esysUtils/EsysException.h" |
#include "esysUtils/EsysException.h" |
28 |
|
|
29 |
Description: |
Description: |
30 |
EsysAssertException exception class. |
EsysAssertException exception class. |
31 |
The class provides a public function returning the exception name. |
The class provides a public function returning the exception name |
32 |
*/ |
*/ |
33 |
class EsysAssertException:public EsysException { |
class EsysAssertException:public EsysException { |
34 |
|
|
35 |
public: |
public: |
|
|
|
36 |
/** |
/** |
37 |
\brief |
\brief |
38 |
Default constructor for the exception. |
Default constructor for the exception. |
39 |
*/ |
*/ |
40 |
EsysAssertException() : EsysException() {} |
EsysAssertException() : EsysException() {} |
|
|
|
41 |
/** |
/** |
42 |
\brief |
\brief |
43 |
Constructor for the exception. |
Constructor for the exception. |
44 |
*/ |
*/ |
45 |
EsysAssertException(const char *cstr) : EsysException(cstr) {} |
EsysAssertException(const char *cstr) : EsysException(cstr) {} |
|
|
|
46 |
/** |
/** |
47 |
\brief |
\brief |
48 |
Constructor for the exception. |
Constructor for the exception. |
49 |
*/ |
*/ |
50 |
EsysAssertException(const std::string &str) : EsysException(str) {} |
EsysAssertException(const std::string &str) : EsysException(str) {} |
|
|
|
51 |
/** |
/** |
52 |
\brief |
\brief |
53 |
Returns the name of the exception. |
Returns the name of the exception. |
54 |
*/ |
*/ |
55 |
virtual std::string exceptionName() const {return "EsysAssertException";} |
virtual std::string exceptionName() const {return "EsysAssertException";} |
|
|
|
56 |
/** |
/** |
57 |
\brief |
\brief |
58 |
Builds a formatted message and throws an EsysAssertException. |
Builds a formatted message and throws an EsysAssertException. |
60 |
static void assertFailure (const std::string& assertion, |
static void assertFailure (const std::string& assertion, |
61 |
const std::string& date, const std::string& file, |
const std::string& date, const std::string& file, |
62 |
int line, const std::string& errDesc) |
int line, const std::string& errDesc) |
63 |
{ |
{ |
64 |
std::stringstream message; |
std::stringstream message; |
65 |
|
|
66 |
message << std::endl |
message << std::endl |
67 |
<< "EsysAssert(" << assertion << ") failed with message - " << std::endl |
<< "EsysAssert(" |
68 |
|
<< assertion |
69 |
|
<< ") failed with message - " << std::endl |
70 |
<< "\"" << errDesc << "\"" << std::endl |
<< "\"" << errDesc << "\"" << std::endl |
71 |
<< "Assertion is located in File : " << file |
<< "Assertion is located in File : " << file |
72 |
<< " at Line: " << line << std::endl |
<< " at Line: " << line << std::endl |
73 |
<< "File Compilation Date: " << date << std::endl; |
<< "File Compilation Date: " << date << std::endl |
74 |
|
<< "To debug - set break point in EsysAssertException::assertFailure" |
75 |
|
<< std::endl |
76 |
|
<< "and examine call stack when breakpoint is reached."; |
77 |
|
|
78 |
throw EsysAssertException(message.str()); |
throw EsysAssertException(message.str()); |
79 |
} |
} |
80 |
|
|
81 |
|
|
82 |
}; |
}; |
83 |
|
|
84 |
} // end of namespace |
} // end of namespace |
85 |
#endif |
#endif |
86 |
|
|
87 |
|
|