ARTS 2.5.11 (git: 6827797f)
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:43
std::string var_string(Args &&... args)
Definition: debug.h:18

Condition should be true to pass internal check

Definition at line 84 of file debug.h.

◆ ARTS_NOEXCEPT

#define ARTS_NOEXCEPT   noexcept(false)

Turn off noexcept

Definition at line 81 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 151 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 135 of file debug.h.

◆ ARTS_USER_NOEXCEPT

#define ARTS_USER_NOEXCEPT   noexcept(false)

Turn off noexcept for user-facing functions

Definition at line 132 of file debug.h.

◆ CURRENT_SOURCE_LOCATION

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

Definition at line 43 of file debug.h.

◆ DEBUG_COUNTER

#define DEBUG_COUNTER (   n)
Value:
{ \
static Index n = 0; \
std::cerr << "DBG: " << #n << ": " << ++n << std::endl; \
}

Definition at line 57 of file debug.h.

◆ DEBUG_ONLY

#define DEBUG_ONLY (   ...)    __VA_ARGS__

Definition at line 53 of file debug.h.

◆ DEBUG_PRINT

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

Definition at line 64 of file debug.h.

◆ DEBUG_VAR

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

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

Function Documentation

◆ var_string()