]> git.ipfire.org Git - thirdparty/squid.git/blob - src/SBufExceptions.cc
MacOS fix: shorten testRock store path to fit in shm segment filename size limitation...
[thirdparty/squid.git] / src / SBufExceptions.cc
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "OutOfBoundsException.h"
11 #include "SBuf.h"
12 #include "SBufExceptions.h"
13
14 OutOfBoundsException::OutOfBoundsException(const SBuf &throwingBuf,
15 SBuf::size_type &pos,
16 const char *aFileName, int aLineNo)
17 : TextException(NULL, aFileName, aLineNo),
18 theThrowingBuf(throwingBuf),
19 accessedPosition(pos)
20 {
21 SBuf explanatoryText("OutOfBoundsException");
22 if (aLineNo != -1)
23 explanatoryText.appendf(" at line %d", aLineNo);
24 if (aFileName != NULL)
25 explanatoryText.appendf(" in file %s", aFileName);
26 explanatoryText.appendf(" while accessing position %d in a SBuf long %d",
27 pos, throwingBuf.length());
28 // we can safely alias c_str as both are local to the object
29 // and will not further manipulated.
30 message = xstrndup(explanatoryText.c_str(),explanatoryText.length());
31 }
32
33 OutOfBoundsException::~OutOfBoundsException() throw()
34 { }
35
36 InvalidParamException::InvalidParamException(const char *aFilename, int aLineNo)
37 : TextException("Invalid parameter", aFilename, aLineNo)
38 { }
39
40 SBufTooBigException::SBufTooBigException(const char *aFilename, int aLineNo)
41 : TextException("Trying to create an oversize SBuf", aFilename, aLineNo)
42 { }
43