diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-02-02 19:56:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-02-02 20:17:35 +0100 |
| commit | 0b59b4f8da889a547a1be03f51118769d73aff2a (patch) | |
| tree | 205b26a4913a38fdcf5d96f77a2bbbade13d23ab /src/lib/dcpomatic_assert.h | |
| parent | ea6b2dae46caa1da829fbf499e83cd6ae3b3773a (diff) | |
boost exception test.
Diffstat (limited to 'src/lib/dcpomatic_assert.h')
| -rw-r--r-- | src/lib/dcpomatic_assert.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/lib/dcpomatic_assert.h b/src/lib/dcpomatic_assert.h index a9851d0f8..b8adc5225 100644 --- a/src/lib/dcpomatic_assert.h +++ b/src/lib/dcpomatic_assert.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,22 @@ */ +#ifndef DCPOMATIC_ASSERT_H +#define DCPOMATIC_ASSERT_H + #include "exceptions.h" +#include <boost/stacktrace.hpp> +#include <boost/exception/all.hpp> + +typedef boost::error_info<struct tag_stacktrace, boost::stacktrace::stacktrace> traced; + +template <class E> +void throw_with_trace(E const& e) +{ + throw boost::enable_error_info(e) << traced(boost::stacktrace::stacktrace()); +} + +#define DCPOMATIC_ASSERT(x) if (!(x)) throw_with_trace(ProgrammingError (__FILE__, __LINE__)); +#define DCPOMATIC_ASSERT_MESSAGE(x, m, ...) if (!(x)) throw_with_trace(ProgrammingError(__FILE__, __LINE__, String::compose(m, __VA_ARGS__))); -#define DCPOMATIC_ASSERT(x) if (!(x)) throw ProgrammingError (__FILE__, __LINE__); +#endif |
