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