1 |
jgs |
82 |
/* |
2 |
|
|
***************************************************************************** |
3 |
|
|
* * |
4 |
|
|
* COPYRIGHT ACcESS - All Rights Reserved * |
5 |
|
|
* * |
6 |
|
|
* This software is the property of ACcESS. No part of this code * |
7 |
|
|
* may be copied in any form or by any means without the expressed written * |
8 |
|
|
* consent of ACcESS. Copying, use or modification of this software * |
9 |
|
|
* by any unauthorised person is illegal unless that person has a software * |
10 |
|
|
* license agreement with ACcESS. * |
11 |
|
|
* * |
12 |
|
|
***************************************************************************** |
13 |
|
|
*/ |
14 |
|
|
|
15 |
|
|
#if !defined escript_EsysAssertException_20040330_H |
16 |
|
|
#define escript_EsysAssertException_20040330_H |
17 |
|
|
|
18 |
|
|
#include "esysUtils/EsysException.h" |
19 |
|
|
|
20 |
|
|
#include <string> |
21 |
|
|
#include <sstream> |
22 |
|
|
|
23 |
|
|
namespace esysUtils { |
24 |
|
|
|
25 |
|
|
/** |
26 |
|
|
\brief |
27 |
|
|
EsysAssertException exception class. |
28 |
|
|
|
29 |
|
|
Description: |
30 |
|
|
EsysAssertException exception class. |
31 |
|
|
The class provides a public function returning the exception name |
32 |
|
|
*/ |
33 |
|
|
class EsysAssertException:public EsysException { |
34 |
|
|
|
35 |
|
|
public: |
36 |
|
|
/** |
37 |
|
|
\brief |
38 |
|
|
Default constructor for the exception. |
39 |
|
|
*/ |
40 |
|
|
EsysAssertException() : EsysException() {} |
41 |
|
|
/** |
42 |
|
|
\brief |
43 |
|
|
Constructor for the exception. |
44 |
|
|
*/ |
45 |
|
|
EsysAssertException(const char *cstr) : EsysException(cstr) {} |
46 |
|
|
/** |
47 |
|
|
\brief |
48 |
|
|
Constructor for the exception. |
49 |
|
|
*/ |
50 |
|
|
EsysAssertException(const std::string &str) : EsysException(str) {} |
51 |
|
|
/** |
52 |
|
|
\brief |
53 |
|
|
Returns the name of the exception. |
54 |
|
|
*/ |
55 |
|
|
virtual std::string exceptionName() const {return "EsysAssertException";} |
56 |
|
|
/** |
57 |
|
|
\brief |
58 |
|
|
Builds a formatted message and throws an EsysAssertException. |
59 |
|
|
*/ |
60 |
|
|
static void assertFailure (const std::string& assertion, |
61 |
|
|
const std::string& date, const std::string& file, |
62 |
|
|
int line, const std::string& errDesc) |
63 |
|
|
{ |
64 |
|
|
std::stringstream message; |
65 |
|
|
|
66 |
|
|
message << std::endl |
67 |
|
|
<< "EsysAssert(" |
68 |
|
|
<< assertion |
69 |
|
|
<< ") failed with message - " << std::endl |
70 |
|
|
<< "\"" << errDesc << "\"" << std::endl |
71 |
|
|
<< "Assertion is located in File : " << file |
72 |
|
|
<< " at Line: " << line << std::endl |
73 |
|
|
<< "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()); |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
}; |
83 |
|
|
|
84 |
|
|
} // end of namespace |
85 |
|
|
#endif |
86 |
|
|
|
87 |
|
|
|