cpp-common
Macros
error.hh File Reference

Brief description here. More...

#include <cstring>
#include <iostream>
#include <optional>
#include "nvsl/common.hh"
#include "nvsl/envvars.hh"
#include "nvsl/trace.hh"
Include dependency graph for error.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PERROR_EXCEPTION(errcode, msg)
 Convert errno to exception. More...
 
#define ASSERT_NON_NULL(val, msg)
 Throw exception with msg if val is NULL. More...
 
#define NVSL_ERROR(msg)
 Throw exception with msg if val is NULL. More...
 
#define NVSL_ERROR_CLEAN(msg)
 Exit with no debugging info. More...
 
#define NVSL_ASSERT(cond, msg)
 Assert a condition w/ msg and generate backtrace on fail. More...
 

Detailed Description

Brief description here.

Date
March 27, 2021

Definition in file error.hh.

Macro Definition Documentation

◆ ASSERT_NON_NULL

#define ASSERT_NON_NULL (   val,
  msg 
)
Value:
do { \
DBGE << msg << std::endl; \
dump_maps(); \
print_trace(); \
if ((val) == NULL) { \
throw std::runtime_error((msg)); \
} \
} while (0);

Throw exception with msg if val is NULL.

Definition at line 31 of file error.hh.

◆ NVSL_ASSERT

#define NVSL_ASSERT (   cond,
  msg 
)
Value:
if (!(cond)) [[unlikely]] { \
DBGE << __FILE__ << ":" << __LINE__ << " Assertion `" << #cond \
<< "' failed: " << msg << std::endl; \
if (not get_env_val(NVSL_NO_STACKTRACE_ENV)) { \
nvsl::print_trace(); \
} \
exit(1); \
}

Assert a condition w/ msg and generate backtrace on fail.

Definition at line 73 of file error.hh.

◆ NVSL_ERROR

#define NVSL_ERROR (   msg)
Value:
do { \
DBGE << msg << std::endl; \
if (not get_env_val(NVSL_NO_STACKTRACE_ENV)) { \
nvsl::dump_maps(); \
nvsl::print_trace(); \
} \
exit(1); \
} while (0);

Throw exception with msg if val is NULL.

Definition at line 53 of file error.hh.

◆ NVSL_ERROR_CLEAN

#define NVSL_ERROR_CLEAN (   msg)
Value:
do { \
DBGE << msg << std::endl; \
exit(1); \
} while (0);

Exit with no debugging info.

Definition at line 65 of file error.hh.

◆ PERROR_EXCEPTION

#define PERROR_EXCEPTION (   errcode,
  msg 
)
Value:
([]() { DBGE << msg << std::endl; }(), nvsl::dump_maps(), \
nvsl::print_trace(), \
std::system_error(errcode, std::generic_category()))

Convert errno to exception.

Definition at line 25 of file error.hh.