]>
Commit | Line | Data |
---|---|---|
412da427 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
412da427 | 3 | * |
bbc27441 AJ |
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. | |
412da427 FC |
7 | */ |
8 | ||
9 | #include "squid.h" | |
10 | #include "OutOfBoundsException.h" | |
11 | #include "SBuf.h" | |
12 | #include "SBufExceptions.h" | |
13 | ||
412da427 FC |
14 | OutOfBoundsException::OutOfBoundsException(const SBuf &throwingBuf, |
15 | SBuf::size_type &pos, | |
16 | const char *aFileName, int aLineNo) | |
f53969cc SM |
17 | : TextException(NULL, aFileName, aLineNo), |
18 | theThrowingBuf(throwingBuf), | |
19 | accessedPosition(pos) | |
412da427 | 20 | { |
412da427 FC |
21 | SBuf explanatoryText("OutOfBoundsException"); |
22 | if (aLineNo != -1) | |
23 | explanatoryText.appendf(" at line %d", aLineNo); | |
496a9e97 | 24 | if (aFileName != NULL) |
412da427 FC |
25 | explanatoryText.appendf(" in file %s", aFileName); |
26 | explanatoryText.appendf(" while accessing position %d in a SBuf long %d", | |
62842d40 | 27 | pos, throwingBuf.length()); |
412da427 FC |
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 | ||
412da427 | 36 | InvalidParamException::InvalidParamException(const char *aFilename, int aLineNo) |
f53969cc | 37 | : TextException("Invalid parameter", aFilename, aLineNo) |
412da427 FC |
38 | { } |
39 | ||
40 | SBufTooBigException::SBufTooBigException(const char *aFilename, int aLineNo) | |
f53969cc | 41 | : TextException("Trying to create an oversize SBuf", aFilename, aLineNo) |
412da427 | 42 | { } |
f53969cc | 43 |