Skip to content
Snippets Groups Projects
Commit aff10f34 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Set AssertError to inherit from std::runtime_error

The main interest is that one can now check more precisely the type of
raised errors in unit tests
parent 0d0d7efb
Branches
Tags
1 merge request!103Set AssertError to inherit from std::runtime_error
......@@ -9,7 +9,7 @@
#include <string>
#include <tuple>
class AssertError
class AssertError : public std::runtime_error
{
private:
const std::string m_file;
......@@ -41,7 +41,8 @@ class AssertError
const std::string& function,
const std::tuple<Args...>& tuple_args,
const std::string_view args_string)
: m_file{filename},
: std::runtime_error(""),
m_file{filename},
m_line{line},
m_function{function},
m_test{[&] {
......@@ -64,7 +65,11 @@ class AssertError
}
}()}
{
;
if (m_message.empty()) {
std::runtime_error::operator=(std::runtime_error(m_test.c_str()));
} else {
std::runtime_error::operator=(std::runtime_error(m_message.c_str()));
}
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment