Kea: exceptions.h File Reference

| Kea 2.2.0

Classes | Namespaces | Macros
exceptions/exceptions.h File Reference
`#include <stdexcept>`
`#include <string>`
`#include <sstream>`
Include dependency graph for exceptions/exceptions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
class | isc::BadValue
| A generic exception that is thrown if a parameter given to a method is considered invalid in that context. More...
class | isc::Exception
| This is a base class for exceptions thrown from the DNS library module. More...
class | isc::InvalidOperation
| A generic exception that is thrown if a function is called in a prohibited way. More...
class | isc::InvalidParameter
| A generic exception that is thrown if a parameter given to a method or function is considered invalid and no other specific exceptions are suitable to describe the error. More...
class | isc::MultiThreadingInvalidOperation
| Exception thrown when a worker thread is trying to stop or pause the respective thread pool (which would result in a dead-lock). More...
class | isc::NotFound
| A generic exception that is thrown when an object can not be found. More...
class | isc::NotImplemented
| A generic exception that is thrown when a function is not implemented. More...
class | isc::OutOfRange
| A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-range data. More...
class | isc::Unexpected
| A generic exception that is thrown when an unexpected error condition occurs. More...

## Namespaces
namespace | isc
| Defines the logger used by the top-level component of kea-lfc.

## Macros
#define | isc_throw(type, stream)
| A shortcut macro to insert known values into exception arguments. More...
#define | isc_throw_1(type, stream, param1)
| Similar as isc_throw, but allows the exception to have one additional parameter (the stream/text goes first) More...
#define | isc_throw_2(type, stream, param1, param2)
| Similar as isc_throw, but allows the exception to have two additional parameters (the stream/text goes first) More...
#define | isc_throw_3(type, stream, param1, param2, param3)
| Similar as isc_throw, but allows the exception to have three additional parameters (the stream/text goes first) More...
#define | isc_throw_4(type, stream, param1, param2, param3, param4)
| Similar as isc_throw, but allows the exception to have four additional parameters (the stream/text goes first) More...

## Macro Definition Documentation

## ◆ isc_throw

#define isc_throw | ( |  | type,
|  |  | stream
| ) |  |

Value:
do { \
std::ostringstream oss__; \
oss__ << stream; \
throw type(__FILE__, __LINE__, oss__.str().c_str()); \
} while (1)

A shortcut macro to insert known values into exception arguments.

It allows the `stream` argument to be part of a statement using an `ostream` object and its `operator<<`. For example,

int x = 10;
isc_throw(SomeException, "Error happened, parameter: " << x);
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition: exceptions/exceptions.h:210

will throw an exception of class `SomeException` whose `what` string will be `"Error happened, parameter: 10"`.

Note: the stream related operations or creation of the exception object may itself throw an exception (specifically `std::bad_alloc`). Even though it should be very rare, we may have to address this issue later.

Note: in general we hate macros and avoid using it in the code. This is one of few exceptions to that policy. inline functions cannot be used for embedding `__FILE__` and `__LINE__`. This is the main reason why this is defined as a macro. The convenience for the ostream is a secondary purpose (if that were the only possible reason we should rather avoid using a macro).

Definition at line 210 of file exceptions/exceptions.h.

## ◆ isc_throw_1

#define isc_throw_1 | ( |  | type,
|  |  | stream,
|  |  | param1
| ) |  |

Value:
do { \
std::ostringstream oss__; \
oss__ << stream; \
throw type(__FILE__, __LINE__, oss__.str().c_str(), param1); \
} while (1)

Similar as isc_throw, but allows the exception to have one additional parameter (the stream/text goes first)

Definition at line 220 of file exceptions/exceptions.h.

## ◆ isc_throw_2

#define isc_throw_2 | ( |  | type,
|  |  | stream,
|  |  | param1,
|  |  | param2
| ) |  |

Value:
do { \
std::ostringstream oss__; \
oss__ << stream; \
throw type(__FILE__, __LINE__, oss__.str().c_str(), param1, param2); \
} while (1)

Similar as isc_throw, but allows the exception to have two additional parameters (the stream/text goes first)

Definition at line 230 of file exceptions/exceptions.h.

## ◆ isc_throw_3

#define isc_throw_3 | ( |  | type,
|  |  | stream,
|  |  | param1,
|  |  | param2,
|  |  | param3
| ) |  |

Value:
do { \
std::ostringstream oss__; \
oss__ << stream; \
throw type(__FILE__, __LINE__, oss__.str().c_str(), param1, param2,\
param3); \
} while (1)

Similar as isc_throw, but allows the exception to have three additional parameters (the stream/text goes first)

Definition at line 240 of file exceptions/exceptions.h.

## ◆ isc_throw_4

#define isc_throw_4 | ( |  | type,
|  |  | stream,
|  |  | param1,
|  |  | param2,
|  |  | param3,
|  |  | param4
| ) |  |

Value:
do { \
std::ostringstream oss__; \
oss__ << stream; \
throw type(__FILE__, __LINE__, oss__.str().c_str(), param1, param2,\
param3, param4); \
} while (1)

Similar as isc_throw, but allows the exception to have four additional parameters (the stream/text goes first)

Definition at line 251 of file exceptions/exceptions.h.