Defines and handles the throwing and printing of exceptions.
More...
#include <ExceptionHandler.h>
|
template<> |
void | exception (const std::string e) |
| Handles an exception that is defined using the input string.
|
|
template<> |
void | exception (const char *const e) |
| Handles an exception that is defined using the input string.
|
|
|
static void | setBehavior (ExceptionBehavior behavior) |
| Set the behavior of the handler.
|
|
template<class Exception > |
static void | exception (const Exception e) |
| Handle an exception derived by std::exception.
|
|
template<typename First , typename... Args> |
static void | exception (std::string exceptionString, First first, Args... args) |
| Handles an exception that is defined using exceptionString as well as multiple arguments.
|
|
static void | rethrow () |
| Rethrows the current exception or prints it.
|
|
static void | setCustomAbortFunction (std::function< void()> function) |
| Set a custom abort function.
|
|
Defines and handles the throwing and printing of exceptions.
This class defines what should happen if an error occurs within AutoPas. For a detailed list please check the enum ExceptionBehavior
◆ exception() [1/4]
template<>
void autopas::utils::ExceptionHandler::exception |
( |
const char *const |
e | ) |
|
Handles an exception that is defined using the input string.
- Parameters
-
e | the string to describe the exception |
◆ exception() [2/4]
template<class Exception >
static void autopas::utils::ExceptionHandler::exception |
( |
const Exception |
e | ) |
|
|
inlinestatic |
Handle an exception derived by std::exception.
If the behavior is set to throw and this function is called in a catch clause, instead of using the passed exception the underlying error is rethrown.
- Parameters
-
e | the exception to be handled |
- Template Parameters
-
Exception | the type of the exception, needed as throw only uses the static type of e |
◆ exception() [3/4]
template<>
void autopas::utils::ExceptionHandler::exception |
( |
const std::string |
e | ) |
|
Handles an exception that is defined using the input string.
- Parameters
-
e | the string to describe the exception |
◆ exception() [4/4]
template<typename First , typename... Args>
void autopas::utils::ExceptionHandler::exception |
( |
std::string |
exceptionString, |
|
|
First |
first, |
|
|
Args... |
args |
|
) |
| |
|
static |
Handles an exception that is defined using exceptionString as well as multiple arguments.
It uses the same fmt library that is also used in spdlog and AutoPasLogger. Call it using e.g.: exception("failure, because {} is not less than {}", 4, 3);
- Template Parameters
-
First | the template type of the first argument |
Args | types of multiple |
- Parameters
-
exceptionString | the basic exception string |
first | the first argument |
args | more arguments |
- Note
- First is needed to differentiate this from the template with exception(const Exception e)
-
this is a variadic function, and can thus incorporate an arbitrary amount of arguments
◆ rethrow()
void autopas::utils::ExceptionHandler::rethrow |
( |
| ) |
|
|
static |
Rethrows the current exception or prints it.
Depending on the set behavior the currently active exception is either rethrown, printed or otherwise handled.
- Note
- Use this only inside a catch clause.
◆ setBehavior()
Set the behavior of the handler.
- Parameters
-
◆ setCustomAbortFunction()
void autopas::utils::ExceptionHandler::setCustomAbortFunction |
( |
std::function< void()> |
function | ) |
|
|
static |
Set a custom abort function.
- Parameters
-
function | the custom abort function |
The documentation for this class was generated from the following files: