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:579
#define ah_fatal_error()
Throws an unconditional std::runtime_error (fatal error)
Definition ah-errors.H:759
#define ah_warning_if(out, C)
Emits a warning to a stream if the condition holds.
Definition ah-errors.H:157
#define ah_invalid_argument_unless(C)
Throws std::invalid_argument if condition does NOT hold.
Definition ah-errors.H:655
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Definition ah-errors.H:522

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 421 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 429 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:421

Definition at line 440 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 437 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 444 of file ah-errors.H.

◆ ah_domain_error

#define ah_domain_error ( )
Value:
std::stringstream() << "(" << __FILE__ << ":" << __LINE__ << ") | "
DynList< T > maps(const C &c, Op op)
Classic map operation.

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:554

*

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

◆ ah_domain_error_if

#define ah_domain_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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 522 of file ah-errors.H.

◆ ah_domain_error_if_constexpr

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

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

◆ ah_domain_error_unless

#define ah_domain_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:538

*

Definition at line 538 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 560 of file ah-errors.H.

◆ ah_fatal_error

#define ah_fatal_error ( )
Value:
std::stringstream() << "(" << __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 759 of file ah-errors.H.

◆ ah_invalid_argument

#define ah_invalid_argument ( )
Value:
std::stringstream() << "(" << __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:671

*

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

◆ ah_invalid_argument_if

#define ah_invalid_argument_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:639

*

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

◆ ah_invalid_argument_if_constexpr

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

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

◆ ah_invalid_argument_unless

#define ah_invalid_argument_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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 655 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 679 of file ah-errors.H.

◆ ah_length_error

#define ah_length_error ( )
Value:
std::stringstream() << "(" << __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:730

*

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

◆ ah_length_error_if

#define ah_length_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:698

*

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

◆ ah_length_error_if_constexpr

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

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

◆ ah_length_error_unless

#define ah_length_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:714

*

Definition at line 714 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 738 of file ah-errors.H.

◆ ah_logic_error

#define ah_logic_error ( )
Value:
std::stringstream() << "(" << __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:341

*

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

◆ ah_logic_error_if

#define ah_logic_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:325

*

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

◆ ah_logic_error_if_constexpr

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

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

◆ ah_logic_error_unless

#define ah_logic_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:309

*

Definition at line 309 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 349 of file ah-errors.H.

◆ ah_out_of_range_error

#define ah_out_of_range_error ( )
Value:
std::stringstream() << "(" << __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:611

*

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

◆ ah_out_of_range_error_if

#define ah_out_of_range_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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 579 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 615 of file ah-errors.H.

◆ ah_out_of_range_error_unless

#define ah_out_of_range_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:595

*

Definition at line 595 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 619 of file ah-errors.H.

◆ ah_overflow_error

#define ah_overflow_error ( )
Value:
std::stringstream() << "(" << __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:495

*

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

◆ ah_overflow_error_if

#define ah_overflow_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:463

*

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

◆ ah_overflow_error_if_constexpr

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

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

◆ ah_overflow_error_unless

#define ah_overflow_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:479

*

Definition at line 479 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 503 of file ah-errors.H.

◆ ah_range_error

#define ah_range_error ( )
Value:
std::stringstream() << "(" << __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:223

*

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

◆ ah_range_error_if

#define ah_range_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:207
__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:4110

*

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

◆ ah_range_error_if_constexpr

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

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

◆ ah_range_error_unless

#define ah_range_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:191

*

Definition at line 191 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 231 of file ah-errors.H.

◆ ah_runtime_error

#define ah_runtime_error ( )
Value:
std::stringstream() << "(" << __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:282

*

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

◆ ah_runtime_error_if

#define ah_runtime_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:266

*

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

◆ ah_runtime_error_if_constexpr

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

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

◆ ah_runtime_error_unless

#define ah_runtime_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:250
fstream file[12]
Definition treapObs.C:67

*

Definition at line 250 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 290 of file ah-errors.H.

◆ ah_underflow_error

#define ah_underflow_error ( )
Value:
std::stringstream() << "(" << __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:400

*

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

◆ ah_underflow_error_if

#define ah_underflow_error_if (   C)
Value:
if (C) \
std::stringstream() << "(" << __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:368

*

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

◆ ah_underflow_error_if_constexpr

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

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

◆ ah_underflow_error_unless

#define ah_underflow_error_unless (   C)
Value:
if (not (C)) \
std::stringstream() << "(" << __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:384

*

Definition at line 384 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 408 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:172

*

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

◆ ah_warning_if

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

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 157 of file ah-errors.H.

◆ ah_warning_unless

#define ah_warning_unless (   out,
 
)
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:141

*

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