Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-errors.H File Reference

Exception handling system with formatted messages for Aleph-w. More...

#include <stdexcept>
#include <sstream>
Include dependency graph for ah-errors.H:

Go to the source code of this file.

Classes

struct  Aleph::ExceptionBuilder< E >
 Exception constructor with formatted message. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Macros

#define ah_warning_unless(out, C)
 Emits a warning to a stream if the condition does NOT hold.
 
#define ah_warning_if(out, C)
 Emits a warning to a stream if the condition holds.
 
#define ah_warning(out)    (out) << "WARNING (" << __FILE__ << ":" << __LINE__ << ") | "
 Emits an unconditional warning to a stream.
 
#define ah_range_error_unless(C)
 Throws std::range_error if condition does NOT hold.
 
#define ah_range_error_if(C)
 Throws std::range_error if condition holds.
 
#define ah_range_error()
 Throws std::range_error unconditionally.
 
#define ah_range_error_if_constexpr(C)
 
#define ah_range_error_unless_constexpr(C)
 
#define ah_runtime_error_unless(C)
 Throws std::runtime_error if condition does NOT hold.
 
#define ah_runtime_error_if(C)
 Throws std::runtime_error if condition holds.
 
#define ah_runtime_error()
 Throws std::runtime_error unconditionally.
 
#define ah_runtime_error_if_constexpr(C)
 
#define ah_runtime_error_unless_constexpr(C)
 
#define ah_logic_error_unless(C)
 Throws std::logic_error if condition does NOT hold.
 
#define ah_logic_error_if(C)
 Throws std::logic_error if condition holds.
 
#define ah_logic_error()
 Throws std::logic_error unconditionally.
 
#define ah_logic_error_if_constexpr(C)
 
#define ah_logic_error_unless_constexpr(C)
 
#define ah_underflow_error_if(C)
 Throws std::underflow_error if condition holds.
 
#define ah_underflow_error_unless(C)
 Throws std::underflow_error if condition does NOT hold.
 
#define ah_underflow_error()
 Throws std::underflow_error unconditionally.
 
#define ah_underflow_error_if_constexpr(C)
 
#define ah_underflow_error_unless_constexpr(C)
 
#define ah_bad_alloc()    do { [[unlikely]] throw std::bad_alloc(); } while (false)
 Throws std::bad_alloc unconditionally (no message stream)
 
#define ah_bad_alloc_if(C)    do { if (C) [[unlikely]] throw std::bad_alloc(); } while (false)
 Throws std::bad_alloc if condition holds.
 
#define ah_bad_alloc_unless(C)    do { if (!(C)) [[unlikely]] throw std::bad_alloc(); } while (false)
 Throws std::bad_alloc if condition does NOT hold.
 
#define ah_bad_alloc_if_constexpr(C)
 
#define ah_bad_alloc_unless_constexpr(C)
 
#define ah_overflow_error_if(C)
 Throws std::overflow_error if condition holds.
 
#define ah_overflow_error_unless(C)
 Throws std::overflow_error if condition does NOT hold.
 
#define ah_overflow_error()
 Throws std::overflow_error unconditionally.
 
#define ah_overflow_error_if_constexpr(C)
 
#define ah_overflow_error_unless_constexpr(C)
 
#define ah_domain_error_if(C)
 Throws std::domain_error if condition holds.
 
#define ah_domain_error_unless(C)
 Throws std::domain_error if condition does NOT hold.
 
#define ah_domain_error()
 Throws std::domain_error unconditionally.
 
#define ah_domain_error_if_constexpr(C)
 
#define ah_domain_error_unless_constexpr(C)
 
#define ah_out_of_range_error_if(C)
 Throws std::out_of_range if condition holds.
 
#define ah_out_of_range_error_unless(C)
 Throws std::out_of_range if condition does NOT hold.
 
#define ah_out_of_range_error()
 Throws std::out_of_range unconditionally.
 
#define ah_out_of_range_error_if_constexpr(C)
 
#define ah_out_of_range_error_unless_constexpr(C)
 
#define ah_invalid_argument_if(C)
 Throws std::invalid_argument if condition holds.
 
#define ah_invalid_argument_unless(C)
 Throws std::invalid_argument if condition does NOT hold.
 
#define ah_invalid_argument()
 Throws std::invalid_argument unconditionally.
 
#define ah_invalid_argument_if_constexpr(C)
 
#define ah_invalid_argument_unless_constexpr(C)
 
#define ah_length_error_if(C)
 Throws std::length_error if condition holds.
 
#define ah_length_error_unless(C)
 Throws std::length_error if condition does NOT hold.
 
#define ah_length_error()
 Throws std::length_error unconditionally.
 
#define ah_length_error_if_constexpr(C)
 
#define ah_length_error_unless_constexpr(C)
 
#define ah_fatal_error()
 Throws an unconditional std::runtime_error (fatal error)
 

Detailed Description

Exception handling system with formatted messages for Aleph-w.

This file provides a complete set of macros to throw standard C++ exceptions with custom messages and automatic code location tracking.

Main Features

  • Macros for all standard C++ exceptions
  • Formatted error messages using stream operator <<
  • Automatic location tracking (file:line) in each exception
  • Optimization with [[unlikely]] for error cases
  • Conditional versions (_if, _unless) for each exception type

Available Exception Types

  • range_error: Values outside valid range
  • runtime_error: Errors detected at runtime
  • logic_error: Program logic errors (bugs)
  • underflow_error: Arithmetic underflow
  • overflow_error: Arithmetic overflow
  • domain_error: Values outside function domain
  • out_of_range: Out of range access in containers
  • invalid_argument: Invalid arguments (most common)
  • length_error: Exceeds size limits

Usage Examples

// Validate index range
ah_out_of_range_error_if(index >= size) << "Index " << index << " out of range";
// Validate arguments
ah_invalid_argument_unless(ptr != nullptr) << "Null pointer not allowed";
// Validate mathematical operations
ah_domain_error_if(x < 0) << "sqrt requires non-negative value";
// Unrecoverable fatal error
ah_fatal_error() << "Corrupted data structure detected";
// Warnings (do not throw exception)
ah_warning_if(std::cerr, size > 1000) << "Large size may impact performance";
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
Definition ah-errors.H:584
#define ah_fatal_error()
Throws an unconditional std::runtime_error (fatal error)
Definition ah-errors.H:764
#define ah_warning_if(out, C)
Emits a warning to a stream if the condition holds.
Definition ah-errors.H:162
#define ah_invalid_argument_unless(C)
Throws std::invalid_argument if condition does NOT hold.
Definition ah-errors.H:660
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Definition ah-errors.H:527

Naming Convention

  • ah_TYPE_error_if(C): Throws exception if C is true
  • ah_TYPE_error_unless(C): Throws exception if C is false
  • ah_warning_if/unless: Emits warning without throwing exception
Author
Leandro Rabindranath Leon
Date
2002-2025 *

Definition in file ah-errors.H.

Macro Definition Documentation

◆ ah_bad_alloc

#define ah_bad_alloc ( )     do { [[unlikely]] throw std::bad_alloc(); } while (false)

Throws std::bad_alloc unconditionally (no message stream)

Definition at line 426 of file ah-errors.H.

◆ ah_bad_alloc_if

#define ah_bad_alloc_if (   C)     do { if (C) [[unlikely]] throw std::bad_alloc(); } while (false)

Throws std::bad_alloc if condition holds.

Definition at line 434 of file ah-errors.H.

◆ ah_bad_alloc_if_constexpr

#define ah_bad_alloc_if_constexpr (   C)
Value:
if constexpr (C) \
#define ah_bad_alloc()
Throws std::bad_alloc unconditionally (no message stream)
Definition ah-errors.H:426

Definition at line 445 of file ah-errors.H.

◆ ah_bad_alloc_unless

#define ah_bad_alloc_unless (   C)     do { if (!(C)) [[unlikely]] throw std::bad_alloc(); } while (false)

Throws std::bad_alloc if condition does NOT hold.

Definition at line 442 of file ah-errors.H.

◆ ah_bad_alloc_unless_constexpr

#define ah_bad_alloc_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 449 of file ah-errors.H.

◆ ah_domain_error

#define ah_domain_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466

Throws std::domain_error unconditionally.

Exceptions
std::domain_erroralways

Throws a domain_error without evaluating any condition. Use when you need to throw directly.

ah_domain_error() << "Value outside function domain";
#define ah_domain_error()
Throws std::domain_error unconditionally.
Definition ah-errors.H:559

*

Definition at line 559 of file ah-errors.H.

◆ ah_domain_error_if

#define ah_domain_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::domain_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::domain_errorif C is true

Useful when a value is outside the valid domain of a function.

ah_domain_error_if(x < 0) << "sqrt requires non-negative input";

*

Definition at line 527 of file ah-errors.H.

◆ ah_domain_error_if_constexpr

#define ah_domain_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 562 of file ah-errors.H.

◆ ah_domain_error_unless

#define ah_domain_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::domain_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::domain_errorif C is false

Useful for validating that a value is in the valid domain.

ah_domain_error_unless(divisor != 0) << "Division by zero";
#define ah_domain_error_unless(C)
Throws std::domain_error if condition does NOT hold.
Definition ah-errors.H:543

*

Definition at line 543 of file ah-errors.H.

◆ ah_domain_error_unless_constexpr

#define ah_domain_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 565 of file ah-errors.H.

◆ ah_fatal_error

#define ah_fatal_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws an unconditional std::runtime_error (fatal error)

Exceptions
std::runtime_erroralways

Useful for situations that should never occur or unrecoverable errors. Does not require a condition.

if (impossible_condition) {
ah_fatal_error() << "This should never happen!";
}

*

Definition at line 764 of file ah-errors.H.

◆ ah_invalid_argument

#define ah_invalid_argument ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::invalid_argument unconditionally.

Exceptions
std::invalid_argumentalways

Throws an invalid_argument error without evaluating any condition. Use when you need to throw directly.

ah_invalid_argument() << "Invalid argument provided";
#define ah_invalid_argument()
Throws std::invalid_argument unconditionally.
Definition ah-errors.H:676

*

Definition at line 676 of file ah-errors.H.

◆ ah_invalid_argument_if

#define ah_invalid_argument_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::invalid_argument if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::invalid_argumentif C is true

Useful for validating function arguments. Most common exception for incorrect parameter validation.

ah_invalid_argument_if(name.empty()) << "Name cannot be empty";
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
Definition ah-errors.H:644

*

Definition at line 644 of file ah-errors.H.

◆ ah_invalid_argument_if_constexpr

#define ah_invalid_argument_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 680 of file ah-errors.H.

◆ ah_invalid_argument_unless

#define ah_invalid_argument_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::invalid_argument if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::invalid_argumentif C is false

Useful for validating that arguments meet required conditions.

ah_invalid_argument_unless(size > 0) << "Size must be positive";

*

Definition at line 660 of file ah-errors.H.

◆ ah_invalid_argument_unless_constexpr

#define ah_invalid_argument_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 684 of file ah-errors.H.

◆ ah_length_error

#define ah_length_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::length_error unconditionally.

Exceptions
std::length_erroralways

Throws a length_error without evaluating any condition. Use when you need to throw directly.

ah_length_error() << "Container size limit exceeded";
#define ah_length_error()
Throws std::length_error unconditionally.
Definition ah-errors.H:735

*

Definition at line 735 of file ah-errors.H.

◆ ah_length_error_if

#define ah_length_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::length_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::length_errorif C is true

Useful when an operation exceeds container size limits.

ah_length_error_if(new_size > max_size()) << "Container size exceeded";
#define ah_length_error_if(C)
Throws std::length_error if condition holds.
Definition ah-errors.H:703

*

Definition at line 703 of file ah-errors.H.

◆ ah_length_error_if_constexpr

#define ah_length_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 739 of file ah-errors.H.

◆ ah_length_error_unless

#define ah_length_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::length_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::length_errorif C is false

Useful for validating that size is within allowed limits.

ah_length_error_unless(size <= max_size()) << "Size exceeds limit";
#define ah_length_error_unless(C)
Throws std::length_error if condition does NOT hold.
Definition ah-errors.H:719

*

Definition at line 719 of file ah-errors.H.

◆ ah_length_error_unless_constexpr

#define ah_length_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 743 of file ah-errors.H.

◆ ah_logic_error

#define ah_logic_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::logic_error unconditionally.

Exceptions
std::logic_erroralways

Throws a logic_error without evaluating any condition. Use when you need to throw directly.

ah_logic_error() << "Program logic invariant violated";
#define ah_logic_error()
Throws std::logic_error unconditionally.
Definition ah-errors.H:346

*

Definition at line 346 of file ah-errors.H.

◆ ah_logic_error_if

#define ah_logic_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::logic_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::logic_errorif C is true

Useful for detecting program logic errors.

ah_logic_error_if(ptr == nullptr) << "Unexpected null pointer";
#define ah_logic_error_if(C)
Throws std::logic_error if condition holds.
Definition ah-errors.H:330

*

Definition at line 330 of file ah-errors.H.

◆ ah_logic_error_if_constexpr

#define ah_logic_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 350 of file ah-errors.H.

◆ ah_logic_error_unless

#define ah_logic_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::logic_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::logic_errorif C is false

Useful for program logic errors (bugs, violated invariants).

ah_logic_error_unless(is_valid_state()) << "Invalid object state";
#define ah_logic_error_unless(C)
Throws std::logic_error if condition does NOT hold.
Definition ah-errors.H:314

*

Definition at line 314 of file ah-errors.H.

◆ ah_logic_error_unless_constexpr

#define ah_logic_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 354 of file ah-errors.H.

◆ ah_out_of_range_error

#define ah_out_of_range_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::out_of_range unconditionally.

Exceptions
std::out_of_rangealways

Throws an out_of_range error without evaluating any condition. Use when you need to throw directly.

ah_out_of_range_error() << "Index out of bounds";
#define ah_out_of_range_error()
Throws std::out_of_range unconditionally.
Definition ah-errors.H:616

*

Definition at line 616 of file ah-errors.H.

◆ ah_out_of_range_error_if

#define ah_out_of_range_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::out_of_range if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::out_of_rangeif C is true

Useful for out of range element access in containers.

ah_out_of_range_error_if(index >= size) << "Index out of bounds";

*

Definition at line 584 of file ah-errors.H.

◆ ah_out_of_range_error_if_constexpr

#define ah_out_of_range_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 620 of file ah-errors.H.

◆ ah_out_of_range_error_unless

#define ah_out_of_range_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::out_of_range if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::out_of_rangeif C is false

Useful for validating valid index access.

ah_out_of_range_error_unless(index < size) << "Invalid index";
#define ah_out_of_range_error_unless(C)
Throws std::out_of_range if condition does NOT hold.
Definition ah-errors.H:600

*

Definition at line 600 of file ah-errors.H.

◆ ah_out_of_range_error_unless_constexpr

#define ah_out_of_range_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 624 of file ah-errors.H.

◆ ah_overflow_error

#define ah_overflow_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::overflow_error unconditionally.

Exceptions
std::overflow_erroralways

Throws an overflow_error without evaluating any condition. Use when you need to throw directly.

ah_overflow_error() << "Arithmetic overflow detected";
#define ah_overflow_error()
Throws std::overflow_error unconditionally.
Definition ah-errors.H:500

*

Definition at line 500 of file ah-errors.H.

◆ ah_overflow_error_if

#define ah_overflow_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::overflow_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::overflow_errorif C is true

Useful for arithmetic operations that result in overflow.

ah_overflow_error_if(result > max_value) << "Arithmetic overflow";
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
Definition ah-errors.H:468

*

Definition at line 468 of file ah-errors.H.

◆ ah_overflow_error_if_constexpr

#define ah_overflow_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 504 of file ah-errors.H.

◆ ah_overflow_error_unless

#define ah_overflow_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::overflow_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::overflow_errorif C is false

Useful for validating absence of arithmetic overflow.

ah_overflow_error_unless(value <= max_limit) << "Value too large";
#define ah_overflow_error_unless(C)
Throws std::overflow_error if condition does NOT hold.
Definition ah-errors.H:484
size_t size_t int32_t value
Definition ca-c-api.h:116

*

Definition at line 484 of file ah-errors.H.

◆ ah_overflow_error_unless_constexpr

#define ah_overflow_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 508 of file ah-errors.H.

◆ ah_range_error

#define ah_range_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::range_error unconditionally.

Exceptions
std::range_erroralways

Throws a range_error without evaluating any condition. Use when you need to throw directly.

ah_range_error() << "Value is out of valid range";
#define ah_range_error()
Throws std::range_error unconditionally.
Definition ah-errors.H:228

*

Definition at line 228 of file ah-errors.H.

◆ ah_range_error_if

#define ah_range_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::range_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::range_errorif C is true

Useful for detecting values out of range.

ah_range_error_if(value < min || value > max) << "Value out of range";
#define ah_range_error_if(C)
Throws std::range_error if condition holds.
Definition ah-errors.H:212
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Definition gmpfrxx.h:4121

*

Examples
blossom_example.cc.

Definition at line 212 of file ah-errors.H.

◆ ah_range_error_if_constexpr

#define ah_range_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 232 of file ah-errors.H.

◆ ah_range_error_unless

#define ah_range_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::range_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::range_errorif C is false

Useful for validating that a value is within a valid range. Error message includes location (file:line).

ah_range_error_unless(index < size) << "Index " << index << " out of range";
#define ah_range_error_unless(C)
Throws std::range_error if condition does NOT hold.
Definition ah-errors.H:196

*

Definition at line 196 of file ah-errors.H.

◆ ah_range_error_unless_constexpr

#define ah_range_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 236 of file ah-errors.H.

◆ ah_runtime_error

#define ah_runtime_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::runtime_error unconditionally.

Exceptions
std::runtime_erroralways

Throws a runtime_error without evaluating any condition. Use when you need to throw directly.

ah_runtime_error() << "Unexpected runtime error occurred";
#define ah_runtime_error()
Throws std::runtime_error unconditionally.
Definition ah-errors.H:287

*

Definition at line 287 of file ah-errors.H.

◆ ah_runtime_error_if

#define ah_runtime_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::runtime_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::runtime_errorif C is true

Useful for detecting runtime error conditions.

ah_runtime_error_if(errno != 0) << "System error: " << strerror(errno);
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
Definition ah-errors.H:271

*

Definition at line 271 of file ah-errors.H.

◆ ah_runtime_error_if_constexpr

#define ah_runtime_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 291 of file ah-errors.H.

◆ ah_runtime_error_unless

#define ah_runtime_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::runtime_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::runtime_errorif C is false

Useful for errors only detected at runtime.

ah_runtime_error_unless(file.is_open()) << "Failed to open file";
#define ah_runtime_error_unless(C)
Throws std::runtime_error if condition does NOT hold.
Definition ah-errors.H:255
ofstream file
Definition writeRb.C:51

*

Definition at line 255 of file ah-errors.H.

◆ ah_runtime_error_unless_constexpr

#define ah_runtime_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 295 of file ah-errors.H.

◆ ah_underflow_error

#define ah_underflow_error ( )
Value:
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::underflow_error unconditionally.

Exceptions
std::underflow_erroralways

Throws an underflow_error without evaluating any condition. Use when you need to throw directly.

ah_underflow_error() << "Arithmetic underflow detected";
#define ah_underflow_error()
Throws std::underflow_error unconditionally.
Definition ah-errors.H:405

*

Definition at line 405 of file ah-errors.H.

◆ ah_underflow_error_if

#define ah_underflow_error_if (   C)
Value:
if (C) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::underflow_error if condition holds.

Parameters
CCondition to evaluate
Exceptions
std::underflow_errorif C is true

Useful for arithmetic operations that result in underflow.

ah_underflow_error_if(result < min_value) << "Arithmetic underflow";
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
Definition ah-errors.H:373

*

Definition at line 373 of file ah-errors.H.

◆ ah_underflow_error_if_constexpr

#define ah_underflow_error_if_constexpr (   C)
Value:
if constexpr (C) \

Definition at line 409 of file ah-errors.H.

◆ ah_underflow_error_unless

#define ah_underflow_error_unless (   C)
Value:
if (not (C)) \
std::ostringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "

Throws std::underflow_error if condition does NOT hold.

Parameters
CCondition to evaluate
Exceptions
std::underflow_errorif C is false

Useful for validating absence of arithmetic underflow.

ah_underflow_error_unless(value >= min_limit) << "Value too small";
#define ah_underflow_error_unless(C)
Throws std::underflow_error if condition does NOT hold.
Definition ah-errors.H:389

*

Definition at line 389 of file ah-errors.H.

◆ ah_underflow_error_unless_constexpr

#define ah_underflow_error_unless_constexpr (   C)
Value:
if constexpr (not (C)) \

Definition at line 413 of file ah-errors.H.

◆ ah_warning

#define ah_warning (   out)     (out) << "WARNING (" << __FILE__ << ":" << __LINE__ << ") | "

Emits an unconditional warning to a stream.

Parameters
outOutput stream where to write the warning

Writes a warning with file and line information without evaluating any condition.

ah_warning(std::cerr) << "Deprecated function called";
#define ah_warning(out)
Emits an unconditional warning to a stream.
Definition ah-errors.H:177

*

Definition at line 177 of file ah-errors.H.

◆ ah_warning_if

#define ah_warning_if (   out,
  C 
)
Value:
if (C) \
[[unlikely]](out) << "WARNING (" << __FILE__ << ":" << __LINE__ << ") | "
size_t size_t int32_t * out
Definition ca-c-api.h:120

Emits a warning to a stream if the condition holds.

Parameters
outOutput stream where to write the warning
CCondition to evaluate

If condition C is true, writes a warning message with file and line information.

ah_warning_if(std::cerr, size > MAX_SIZE) << "Size exceeds maximum";

*

Definition at line 162 of file ah-errors.H.

◆ ah_warning_unless

#define ah_warning_unless (   out,
  C 
)
Value:
if (not (C)) \
[[unlikely]](out) << "WARNING (" << __FILE__ << ":" << __LINE__ << ") | "

Emits a warning to a stream if the condition does NOT hold.

Parameters
outOutput stream where to write the warning
CCondition to evaluate

If condition C is false, writes a warning message with file and line information. Typical use with std::cerr.

ah_warning_unless(std::cerr, ptr != nullptr) << "Pointer is null";
#define ah_warning_unless(out, C)
Emits a warning to a stream if the condition does NOT hold.
Definition ah-errors.H:146

*

Definition at line 146 of file ah-errors.H.