PGROUTING
3.2
|
An assert functionality that uses C++ throw(). More...
#include <string>
#include <exception>
Go to the source code of this file.
Classes | |
class | AssertFailedException |
Extends std::exception and is the exception that we throw if an assert fails. More... | |
Macros | |
#define | __STRING(x) #x |
#define | __TOSTRING(x) __STRING(x) |
#define | pgassert(expr) |
Uses the standard assert syntax. More... | |
#define | pgassertwm(expr, msg) |
Adds a message to the assertion. More... | |
Functions | |
std::string | get_backtrace () |
returns the execution path of the trace More... | |
std::string | get_backtrace (const std::string &) |
An assert functionality that uses C++ throw().
Assertions Handling
This file provides an alternative to assert functionality that will convert all pgassert() into C++ throw using an AssertFailedException class.
This allows catching errors and do appropriate clean up re-throw if needed to catch errors in the postgresql environment
Do not crash the backend server.
Definition in file pgr_assert.h.
#define __STRING | ( | x | ) | #x |
Definition at line 55 of file pgr_assert.h.
#define __TOSTRING | ( | x | ) | __STRING(x) |
Definition at line 58 of file pgr_assert.h.
#define pgassert | ( | expr | ) |
Uses the standard assert syntax.
When an assertion fails it will throw AssertFailedException and what() will return a string like "AssertFailedException(2+2 == 5) at t.cpp:11"
Example:
Definition at line 94 of file pgr_assert.h.
#define pgassertwm | ( | expr, | |
msg | |||
) |
Adds a message to the assertion.
Example:
Definition at line 117 of file pgr_assert.h.
std::string get_backtrace | ( | ) |
returns the execution path of the trace
In case of a failed exception the backtrace can be is shown in the error message.
Does not work for windows, please read: http://stackoverflow.com/questions/27639931/can-not-find-execinfo-h-when-setup-malpack
Definition at line 40 of file pgr_assert.cpp.
Referenced by get_backtrace().
std::string get_backtrace | ( | const std::string & | ) |
Definition at line 61 of file pgr_assert.cpp.
References get_backtrace().