]> git.ipfire.org Git - thirdparty/squid.git/blob - src/TextException.h
SourceFormat: enforcement
[thirdparty/squid.git] / src / TextException.h
1 #ifndef SQUID__TEXTEXCEPTION_H
2 #define SQUID__TEXTEXCEPTION_H
3
4 // Origin: xstd/TextException
5
6 #include "squid.h"
7 #include <exception>
8
9 // simple exception to report custom errors
10 // we may want to change the interface to be able to report system errors
11
12 class TextException: public std::exception
13 {
14
15 public:
16 TextException();
17 TextException(const char *aMessage, const char *aFileName = 0, int aLineNo = -1);
18 TextException(const TextException& right);
19 virtual ~TextException() throw();
20
21 virtual const char *what() const throw();
22
23 TextException& operator=(const TextException &right);
24
25 public:
26 char *message; // read-only
27
28 protected:
29 // optional location information
30 const char *theFileName;
31 int theLineNo;
32 };
33
34 //inline
35 //ostream &operator <<(ostream &os, const TextException &exx) {
36 // return exx.print(os);
37 //}
38
39 #if !defined(TexcHere)
40 # define TexcHere(msg) TextException((msg), __FILE__, __LINE__)
41 #endif
42
43 extern void Throw(const char *message, const char *fileName, int lineNo);
44
45 // Must(condition) is like assert(condition) but throws an exception instead
46 #if !defined(Must)
47 # define Must(cond) ((cond) ? \
48 (void)0 : \
49 (void)Throw(#cond, __FILE__, __LINE__))
50 #endif
51
52 #endif /* SQUID__TEXTEXCEPTION_H */