]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/TextException.cc
2 #include "base/TextException.h"
6 TextException::TextException()
14 TextException::TextException(const TextException
& right
) :
15 message((right
.message
?xstrdup(right
.message
):NULL
)), theFileName(right
.theFileName
), theLineNo(right
.theLineNo
), theId(right
.theId
)
19 TextException::TextException(const char *aMsg
, const char *aFileName
, int aLineNo
, unsigned int anId
):
20 message(xstrdup(aMsg
)), theFileName(aFileName
), theLineNo(aLineNo
), theId(anId
)
23 TextException::~TextException() throw()
25 if (message
) xfree(message
);
28 TextException
& TextException::operator=(const TextException
&right
)
30 if (this==&right
) return *this;
31 if (message
) xfree(message
);
32 message
=(right
.message
?xstrdup(right
.message
):NULL
);
33 theFileName
=right
.theFileName
;
34 theLineNo
=right
.theLineNo
;
39 const char *TextException::what() const throw()
41 /// \todo add file:lineno
42 return message
? message
: "TextException without a message";
45 unsigned int TextException::FileNameHash(const char *fname
)
51 s
= strrchr(fname
, '/');
60 n
^= 271 * (unsigned) *s
;
64 /*18bits of a 32 bit integer used for filename hash (max hash=262143),
65 and 14 bits for storing line number (16k max).
66 If you change this policy remember to update the FileNameHash function
67 in the scripts/calc-must-ids.pl script
72 void Throw(const char *message
, const char *fileName
, int lineNo
, unsigned int id
)
75 // or should we let the exception recepient print the exception instead?
78 debugs(0, 3, fileName
<< ':' << lineNo
<< ": exception" <<
79 (message
? ": " : ".") << (message
? message
: ""));
81 debugs(0, 3, "exception" <<
82 (message
? ": " : ".") << (message
? message
: ""));
85 throw TextException(message
, fileName
, lineNo
, id
);