Thrown when an assertion fails.
More...
#include <kaycxx/assert/assertion_error.hpp>
Thrown when an assertion fails.
◆ assertion_error()
| kaycxx::assert::assertion_error::assertion_error |
( |
std::string const & |
message, |
|
|
std::string_view |
reason, |
|
|
std::string |
actual, |
|
|
std::string |
expected, |
|
|
std::optional< std::source_location > |
location = std::nullopt |
|
) |
| |
|
explicit |
Creates an assertion error with already-rendered diagnostic values.
The reason is appended to the exception message when present and is also stored separately. Actual and expected values are stored as rendered strings so the exception type stays non-template and easy to catch.
- Parameters
-
| message | Assertion message without the optional reason suffix. |
| reason | Optional assertion reason. |
| actual | Rendered actual value. |
| expected | Rendered expected value. |
| location | Optional source location of the failed assertion. |
◆ actual()
| std::string const & kaycxx::assert::assertion_error::actual |
( |
| ) |
const |
|
noexcept |
Returns the rendered actual value.
- Returns
- Rendered actual value.
◆ expected()
| std::string const & kaycxx::assert::assertion_error::expected |
( |
| ) |
const |
|
noexcept |
Returns the rendered expected value.
- Returns
- Rendered expected value.
◆ location()
| std::optional< std::source_location > const & kaycxx::assert::assertion_error::location |
( |
| ) |
const |
|
noexcept |
Returns the source location of the failed assertion.
- Returns
- Optional source location of the failed assertion.
◆ reason()
| std::string const & kaycxx::assert::assertion_error::reason |
( |
| ) |
const |
|
noexcept |
Returns the optional assertion reason.
- Returns
- Optional assertion reason, or an empty string when no reason was provided.
The documentation for this class was generated from the following file: