Drake
drake_throw.h File Reference

Provides a convenient wrapper to throw an exception when a condition is unmet. More...

#include <type_traits>
#include "drake/common/drake_assert.h"
Include dependency graph for drake_throw.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 drake
 
 drake::detail
 

Macros

#define DRAKE_THROW_UNLESS(condition)
 Evaluates condition and iff the value is false will throw an exception with a message showing at least the condition text, function name, file, and line. More...
 

Functions

 __attribute__ ((noreturn)) void Throw(const char *condition
 

Variables

const char * func
 
const char const char * file
 
const char const char int line
 

Detailed Description

Provides a convenient wrapper to throw an exception when a condition is unmet.

This is similar to an assertion, but uses exceptions instead of ::abort(), and cannot be disabled.

Macro Definition Documentation

#define DRAKE_THROW_UNLESS (   condition)
Value:
do { \
typedef ::drake::assert::ConditionTraits< \
typename std::remove_cv<decltype(condition)>::type> Trait; \
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
if (!Trait::Evaluate(condition)) { \
::drake::detail::Throw(#condition, __func__, __FILE__, __LINE__); \
} \
} while (0)
void Throw(const char *condition, const char *func, const char *file, int line)
Definition: drake_assert_and_throw.cc:53

Evaluates condition and iff the value is false will throw an exception with a message showing at least the condition text, function name, file, and line.