maliput
maliput_throw.h File Reference
#include <string>
Include dependency graph for maliput_throw.h:
This graph shows which files directly or indirectly include this file:

Namespaces

 maliput
 Code in this file is inspired by: https://github.com/RobotLocomotion/drake/blob/master/common/text_logging.h.
 
 maliput::common
 
 maliput::common::internal
 

Macros

#define MALIPUT_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...
 
#define MALIPUT_THROW_MESSAGE(msg)
 Throws an exception with a message showing at least the condition text, function name, file, and line. More...
 
#define MALIPUT_VALIDATE(pred, message)
 
#define MALIPUT_IS_IN_RANGE(value, min_value, max_value)
 

Functions

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

Macro Definition Documentation

◆ MALIPUT_IS_IN_RANGE

#define MALIPUT_IS_IN_RANGE (   value,
  min_value,
  max_value 
)
Value:
do { \
MALIPUT_VALIDATE(value >= min_value, std::to_string(value) + " is less than " + std::to_string(min_value)); \
MALIPUT_VALIDATE(value <= max_value, std::to_string(value) + " is greater than " + std::to_string(max_value)); \
} while (0)

Throws if value is within [min_value; max_value]. It forwards the call to MALIPUT_VALIDATE() with a customized string stating the error.

◆ MALIPUT_THROW_MESSAGE

#define MALIPUT_THROW_MESSAGE (   msg)
Value:
do { \
const std::string error_message(msg); \
::maliput::common::internal::Throw(error_message.c_str(), __func__, __FILE__, __LINE__); \
} while (0)

Throws an exception with a message showing at least the condition text, function name, file, and line.

◆ MALIPUT_THROW_UNLESS

#define MALIPUT_THROW_UNLESS (   condition)
Value:
do { \
if (!(condition)) { \
::maliput::common::internal::Throw(#condition, __func__, __FILE__, __LINE__); \
} \
} while (0)

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.

◆ MALIPUT_VALIDATE

#define MALIPUT_VALIDATE (   pred,
  message 
)
Value:
do { \
if (!(pred)) { \
::maliput::common::internal::Throw(std::string(message).c_str(), __func__, __FILE__, __LINE__); \
} \
} while (0)

Used to validate that a pred-icate passed into a function or method is true; if not, an exception with message is thrown.

maliput::drake::to_string
std::string to_string(const maliput::drake::Identifier< Tag > &id)
Enables use of identifiers with to_string.
Definition: identifier.h:228
maliput::common::internal::Throw
void Throw(const char *condition, const char *func, const char *file, int line)
Definition: maliput_abort_and_throw.cc:111