ARTS 2.5.10 (git: 2f1c442c)
debug.h File Reference

Helper macros for debugging. More...

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

Go to the source code of this file.

Macros

#define CURRENT_SOURCE_LOCATION   var_string("\t", __FILE__, ":", __LINE__)
 
#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", \
"\nPlease contact" \
" ARTS developers so we can fix " \
"our error(s) via:\n\t" \
"github.com/atmtools/arts\n" __VA_OPT__(, __VA_ARGS__))); \
} \
}
#define CURRENT_SOURCE_LOCATION
Definition: debug.h:61
std::string var_string(Args &&... args)
Definition: debug.h:36

Condition should be true to pass internal check

Definition at line 102 of file debug.h.

◆ ARTS_NOEXCEPT

#define ARTS_NOEXCEPT   noexcept(false)

Turn off noexcept

Definition at line 99 of file debug.h.

◆ ARTS_USER_ERROR

#define ARTS_USER_ERROR (   ...)
Value:
{ \
static_assert(false __VA_OPT__(or true), \
"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", \
"\nPlease follow " \
"these instructions to correct your " \
"error:\n" __VA_OPT__(, __VA_ARGS__))); \
}

An error has occured, will throw the error

Definition at line 169 of file debug.h.

◆ ARTS_USER_ERROR_IF

#define ARTS_USER_ERROR_IF (   condition,
  ... 
)
Value:
{ \
static_assert(false __VA_OPT__(or true), \
"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", \
"\nPlease follow " \
"these instructions to correct your " \
"error:\n" __VA_OPT__(, __VA_ARGS__))); \
} \
}

Condition should be false to pass external check

Definition at line 153 of file debug.h.

◆ ARTS_USER_NOEXCEPT

#define ARTS_USER_NOEXCEPT   noexcept(false)

Turn off noexcept for user-facing functions

Definition at line 150 of file debug.h.

◆ CURRENT_SOURCE_LOCATION

#define CURRENT_SOURCE_LOCATION   var_string("\t", __FILE__, ":", __LINE__)

Definition at line 61 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 75 of file debug.h.

◆ DEBUG_ONLY

#define DEBUG_ONLY (   ...)    __VA_ARGS__

Definition at line 71 of file debug.h.

◆ DEBUG_PRINT

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

Definition at line 82 of file debug.h.

◆ DEBUG_VAR

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

Definition at line 86 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 90 of file debug.h.

Function Documentation

◆ var_string()