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

Custom exception classes with source location tracking. More...

#include <exception>
#include <sstream>
#include <ahUtils.H>
Include dependency graph for aleph-exceptions.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  AlephException
 Aleph exception class. More...
 
struct  MinMaxReversed
 
struct  InvalidCsvHeader
 
struct  InvalidCsvRow
 
struct  InvalidValue
 
struct  OutOfMemory
 
struct  OutOfRange
 
struct  ValueNotFound
 
struct  CommandLineError
 
struct  InvariantError
 
struct  SizeMismatch
 
struct  InvalidConversion
 
struct  NameNotFound
 
struct  InvalidSize
 
struct  InvalidRange
 
struct  InvalidUnit
 
struct  DuplicatedOperation
 
struct  DuplicatedName
 
struct  InvalidRead
 
struct  FileNotFound
 

Macros

#define DEFINE_ALEPH_EXCEPTION(name, category_msg)
 Define a new exception.
 
#define ALEPHTHROW(type, msg)   throw type(__LINE__, __FILE__, #type, msg)
 Macro for throwing an aleph exception.
 

Detailed Description

Custom exception classes with source location tracking.

This file provides AlephException, a custom exception class that captures file name, line number, and function name where the exception was thrown.

Key Features

  • Inherits from std::runtime_error
  • Captures source location (file, line, function)
  • Human-readable error messages
  • Macro for defining new exception types

AlephException Members

  • line_number: Line where exception was thrown
  • file_name: Source file name
  • function_name: Function where thrown

Defining Custom Exceptions

Use the DEFINE_ALEPH_EXCEPTION macro:

// Usage:
throw MyError(__FILE__, __LINE__, "my_function", "Something failed");
#define DEFINE_ALEPH_EXCEPTION(name, category_msg)
Define a new exception.

Recommended Alternative

For new code, prefer using ah-errors.H macros which provide automatic source location capture:

ah_domain_error_if(x < 0, "x must be positive");
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Definition ah-errors.H:522
See also
ah-errors.H Modern error handling macros
ahUtils.H Utility functions used by exceptions
Author
Leandro Rabindranath León

Definition in file aleph-exceptions.H.

Macro Definition Documentation

◆ ALEPHTHROW

#define ALEPHTHROW (   type,
  msg 
)    throw type(__LINE__, __FILE__, #type, msg)

Macro for throwing an aleph exception.

Parameters
[in]typealeph exception class name
[in]msgmessage describing the error
Author
Leandro Rabindranath León

Definition at line 162 of file aleph-exceptions.H.

◆ DEFINE_ALEPH_EXCEPTION

#define DEFINE_ALEPH_EXCEPTION (   name,
  category_msg 
)
Value:
struct name : public AlephException \
{ \
name(const size_t line_number, \
const std::string & file_name, \
const std::string & type, \
const std::string & msg) \
: AlephException(#category_msg, line_number, file_name, type, msg) {} \
};
Aleph exception class.

Define a new exception.

Parameters
[in]nameof the exception
[in]category_msg
Author
Leandro Rabindranath Leon

Definition at line 145 of file aleph-exceptions.H.