ARTS 2.5.0 (git: 9ee3ac6c)
debug.h File Reference

Helper macros for debugging. More...

#include <sstream>
#include <string>
#include <tuple>
#include <exception>
#include <iostream>

Go to the source code of this file.

Macros

#define DEBUG_ONLY(...)   __VA_ARGS__
 
#define DEBUG_COUNTER(n)
 
#define DEBUG_PRINT(e)    { std::cerr << "DBG: " << (e) << std::endl; }
 
#define DEBUG_VAR(e)    { std::cerr << "DBG: " << #e << ": " << (e) << std::endl; }
 
#define DEBUG_VAR_FLT(p, e)
 
#define ARTS_NOEXCEPT   noexcept(false)
 
#define ARTS_ASSERT(condition, ...)
 
#define ARTS_USER_NOEXCEPT   noexcept(false)
 
#define ARTS_USER_ERROR_IF(condition, ...)
 
#define ARTS_USER_ERROR(...)
 

Functions

template<typename ... Args>
std::string var_string (Args &&... args)
 

Detailed Description

Helper macros for debugging.

Author
Oliver Lemke
Date
2013-04-25

Definition in file debug.h.

Macro Definition Documentation

◆ ARTS_ASSERT

#define ARTS_ASSERT (   condition,
  ... 
)
Value:
{ \
if (not (condition)) { \
throw std::runtime_error( \
var_string("Failed Internal Assert: " \
#condition "\n" "This is a bug! " \
"Bug is found at:\n\t" __FILE__ \
":", __LINE__, "\nPlease contact" \
" ARTS developers so we can fix " \
"our error(s) via:\n\t" \
"github.com/atmtools/arts\n") + \
var_string(__VA_ARGS__) \
); \
} }
std::string var_string(Args &&... args)
Definition: debug.h:36

Condition should be true to pass internal check

Definition at line 83 of file debug.h.

◆ ARTS_NOEXCEPT

#define ARTS_NOEXCEPT   noexcept(false)

Turn off noexcept

Definition at line 80 of file debug.h.

◆ ARTS_USER_ERROR

#define ARTS_USER_ERROR (   ...)
Value:
{ \
static_assert(std::tuple_size<decltype( \
std::make_tuple(__VA_ARGS__))>::value, \
"Must have an error message in user-" \
"facing code in " __FILE__); \
throw std::runtime_error( \
var_string("User Error:\n" \
"Error is found at:\n\t" __FILE__ \
":", __LINE__, "\nPlease follow " \
"these instructions to correct your " \
"error:\n") + var_string(__VA_ARGS__) \
); \
}

An error has occured, will throw the error

Definition at line 150 of file debug.h.

◆ ARTS_USER_ERROR_IF

#define ARTS_USER_ERROR_IF (   condition,
  ... 
)
Value:
{ \
static_assert(std::tuple_size<decltype( \
std::make_tuple(__VA_ARGS__))>::value, \
"Must have an error message in user-" \
"facing code in " __FILE__); \
if (condition) { \
throw std::runtime_error( \
var_string("User Error: " #condition \
"\nError is found at:\n\t" __FILE__ \
":", __LINE__, "\nPlease follow " \
"these instructions to correct your " \
"error:\n") + var_string(__VA_ARGS__) \
); \
} }

Condition should be false to pass external check

Definition at line 134 of file debug.h.

◆ ARTS_USER_NOEXCEPT

#define ARTS_USER_NOEXCEPT   noexcept(false)

Turn off noexcept for user-facing functions

Definition at line 131 of file debug.h.

◆ DEBUG_COUNTER

#define DEBUG_COUNTER (   n)
Value:
{ \
static Index n = 0; \
std::cerr << "DBG: " << #n << ": " << ++n << std::endl; \
}
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39

Definition at line 56 of file debug.h.

◆ DEBUG_ONLY

#define DEBUG_ONLY (   ...)    __VA_ARGS__

Definition at line 52 of file debug.h.

◆ DEBUG_PRINT

#define DEBUG_PRINT (   e)     { std::cerr << "DBG: " << (e) << std::endl; }

Definition at line 63 of file debug.h.

◆ DEBUG_VAR

#define DEBUG_VAR (   e)     { std::cerr << "DBG: " << #e << ": " << (e) << std::endl; }

Definition at line 67 of file debug.h.

◆ DEBUG_VAR_FLT

#define DEBUG_VAR_FLT (   p,
 
)
Value:
{ \
std::streamsize old_p = std::cerr.precision(); \
std::cerr << "DBG: " << #e << ": " << std::setprecision(p) << (e) \
<< std::endl \
<< std::setprecision(old_p); \
}

Definition at line 71 of file debug.h.

Function Documentation

◆ var_string()

template<typename ... Args>
std::string var_string ( Args &&...  args)

Take all arguments and turn to string by their operator<<()

Definition at line 36 of file debug.h.

Referenced by atmgeom_checkedCalc(), chk_griddedfield_gridname(), chk_interpolation_grids(), GriddedField::get_numeric_grid(), and GriddedField::get_string_grid().