crocoddyl
1.6.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
exception.hpp
1
// BSD 3-Clause License
3
//
4
// Copyright (C) 2019-2020, University of Edinburgh, LAAS-CNRS
5
// Copyright note valid unless otherwise stated in individual files.
6
// All rights reserved.
8
9
#ifndef CROCODDYL_CORE_UTILS_EXCEPTION_HPP_
10
#define CROCODDYL_CORE_UTILS_EXCEPTION_HPP_
11
12
#include <exception>
13
#include <sstream>
14
15
#include "crocoddyl/core/utils/to-string.hpp"
16
17
#if __cplusplus >= 201103L // We are using C++11 or a later version
18
#define NOEXCEPT noexcept
19
#else
20
#define NOEXCEPT throw()
21
#endif
22
23
#define throw_pretty(m) \
24
{ \
25
std::stringstream ss; \
26
ss << m; \
27
throw crocoddyl::Exception(ss.str(), __FILE__, __PRETTY_FUNCTION__, __LINE__); \
28
}
29
30
#ifndef NDEBUG
31
#define assert_pretty(condition, m) \
32
if (!(condition)) { \
33
std::stringstream ss; \
34
ss << m; \
35
throw crocoddyl::Exception(ss.str(), __FILE__, __PRETTY_FUNCTION__, __LINE__); \
36
}
37
#else
38
#define assert_pretty(condition, m) ((void)0)
39
#endif
40
namespace
crocoddyl
{
41
42
class
Exception
:
public
std::exception {
43
public
:
44
explicit
Exception
(
const
std::string &msg,
const
char
*file,
const
char
*func,
int
line);
45
virtual
~
Exception
() NOEXCEPT;
46
virtual
const
char
*what()
const
NOEXCEPT;
47
48
std::string msg_;
49
};
50
51
}
// namespace crocoddyl
52
53
#endif // CROCODDYL_CORE_UTILS_EXCEPTION_HPP_
crocoddyl::Exception
Definition:
exception.hpp:42
crocoddyl
Definition:
action-base.hpp:21
include
crocoddyl
core
utils
exception.hpp
Generated by
1.8.13