CARMA C++
|
Exception class for errors. More...
#include <string>
#include <iosfwd>
#include <log4cpp/Priority.hh>
#include "carma/util/BaseException.h"
Go to the source code of this file.
Classes | |
class | carma::util::ErrorException |
Exception class for errors The exception comes with a text string that can be printed or logged. More... | |
Namespaces | |
module | carma |
IDL for bima Rx Control, inherits from antenna::common::RxControl. | |
carma::util | |
Utility classes. | |
Macros | |
#define | CARMA_ASSERT(assertion) |
#define | CARMA_ERROR(y) |
Trick to get the file name and line number passed to the exception handler. More... | |
#define | MAKE_DERIVED_ERROR_EXCEPTION(T) |
#define | ThrowCarmaError(text) |
#define | ThrowCarmaException(exception, text) |
#define | ThrowCarmaUserException(text) |
Functions | |
::std::ostream & | operator<< (::std::ostream &os, const ::std::exception &error) |
Insert (i.e. output) the error message from any ::std::exception into an output stream. More... | |
Exception class for errors.
This class allocates memory to form the final message and is therefore subject to the hazard of running out of resources. If this happens, with a new exception being thrown in the constructor of an exception, then the result is an uncaught exception. You are advised to use carma::util::BaseException if a safer exception is desired.
We use some tricks to ensure that the file name and line number of the location where the exception is created is captured by the exception handler. The actual constructor uses three parameters, but most common use will be via the CARMA_ERROR macro, defined at the end of this file. This macro uses only a single parameter thus allowing it to get the filename and line number at compile time.
The full error message that is created always has the file and line number preceeding the user supplied message.
$CarmaCopyright$
Definition in file ErrorException.h.
#define CARMA_ASSERT | ( | assertion | ) |
Definition at line 189 of file ErrorException.h.
#define CARMA_ERROR | ( | y | ) |
Trick to get the file name and line number passed to the exception handler.
Definition at line 171 of file ErrorException.h.
#define MAKE_DERIVED_ERROR_EXCEPTION | ( | T | ) |
Definition at line 208 of file ErrorException.h.
#define ThrowCarmaError | ( | text | ) |
Definition at line 175 of file ErrorException.h.
#define ThrowCarmaException | ( | exception, | |
text | |||
) |
Definition at line 198 of file ErrorException.h.
#define ThrowCarmaUserException | ( | text | ) |
Definition at line 182 of file ErrorException.h.
std::ostream & operator<< | ( | ::std::ostream & | os, |
const ::std::exception & | error | ||
) |
Insert (i.e. output) the error message from any ::std::exception into an output stream.
Typical usage is like so:
os | The output stream to insert the message into. |
error | The exception to get the message from. |
os
output stream parameter so that stream insertions can be chained in the usual C++ way (as shown in the example).