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