43 armarx::LocalException(
"The following expression is not true, but needs to be: '" +
45 expression(expression)
52 return "armarx::exceptions::local::ExpressionException";
62 std::string expression;
73 #define ARMARX_CHECK_EXPRESSION(expression) \
75 throw ::armarx::exceptions::local::ExpressionException(#expression) \
76 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
82 #define ARMARX_CHECK(expression) ARMARX_CHECK_EXPRESSION(expression)
90 #define ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, cmp) \
92 throw ::armarx::exceptions::local::ExpressionException(#lhs " " #cmp " " #rhs) \
93 << "\n(lhs = " << lhs << ", rhs = " << rhs << ")" \
94 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
102 #define ARMARX_CHECK_LESS(lhs, rhs) ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, <)
109 #define ARMARX_CHECK_LESS_EQUAL(lhs, rhs) ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, <=)
116 #define ARMARX_CHECK_GREATER(lhs, rhs) ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, >)
123 #define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs) ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, >=)
130 #define ARMARX_CHECK_EQUAL(lhs, rhs) ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, ==)
137 #define ARMARX_CHECK_NOT_EQUAL(lhs, rhs) ARMARX_CHECK_BINARY_PREDICATE(lhs, rhs, !=)
145 #define ARMARX_CHECK_POSITIVE(number) ARMARX_CHECK_GREATER(number, 0)
152 #define ARMARX_CHECK_NONNEGATIVE(number) ARMARX_CHECK_GREATER_EQUAL(number, 0)
159 #define ARMARX_CHECK_FITS_SIZE(number, size) \
160 ARMARX_CHECK_NONNEGATIVE(number); \
161 ARMARX_CHECK_LESS(size_t(number), size)
169 #define ARMARX_CHECK_CLOSE(lhs, rhs, prec) \
170 if (!(std::abs(lhs - rhs) <= prec)) \
171 throw ::armarx::exceptions::local::ExpressionException("| " #lhs " - " #rhs "| <= " #prec) \
172 << "\n(lhs = " << lhs << ", rhs = " << rhs << ", prec = " << prec << ")" \
173 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
182 #define ARMARX_CHECK_FINITE(number) \
183 if (!(std::isfinite(number))) \
184 throw ::armarx::exceptions::local::ExpressionException("std::isfinite(" #number ")") \
185 << "\n(number = " << number << ")" \
186 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
194 #define ARMARX_CHECK_IS_NULL(ptr) \
196 throw ::armarx::exceptions::local::ExpressionException(#ptr " == nullptr") \
197 << "\n(ptr = " << ptr << ")" \
198 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
206 #define ARMARX_CHECK_NOT_NULL(ptr) \
208 throw ::armarx::exceptions::local::ExpressionException(#ptr " != nullptr") \
209 << "\n(ptr = nullptr)" \
210 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
212 #define ARMARX_CHECK_NULL(ptr) \
214 throw ::armarx::exceptions::local::ExpressionException(#ptr " == nullptr") \
215 << "\n(ptr = nullptr)" \
216 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
218 #define ARMARX_CHECK_EMPTY(c) \
220 throw ::armarx::exceptions::local::ExpressionException(#c ".empty()") \
221 << "\n(c = " << c << ")" \
222 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
224 #define ARMARX_CHECK_NOT_EMPTY(c) \
226 throw ::armarx::exceptions::local::ExpressionException("not " #c ".empty()") \
227 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
229 #define ARMARX_CHECK_MULTIPLE_OF(val, mod) \
230 if ((val % mod) != 0) \
231 throw ::armarx::exceptions::local::ExpressionException("valis a multiple of mod") \
232 << "\n(val = " << val << ", mod = " << mod << ")" \
233 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
235 #define ARMARX_CHECK_NOT_MULTIPLE_OF(val, mod) \
236 if ((val % mod) == 0) \
237 throw ::armarx::exceptions::local::ExpressionException("val is not a multiple of mod") \
238 << "\n(val = " << val << ", mod = " << mod << ")" \
239 << "\n(at " << __FILE__ << ':' << __LINE__ << " in " << __FUNCTION__ << "(...))\n"
245 #define ARMARX_CHECK_AND_THROW(expression, ExceptionType) \
249 throw ExceptionType(#expression); \
253 #define eigen_assert(expression) ARMARX_CHECK_EXPRESSION(expression)