Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
exception_ctx.hpp File Reference

Provides utilities for adding context to exceptions. More...

#include "shambase/SourceLocation.hpp"
#include "shambase/exception.hpp"
#include "shambase/string.hpp"
#include <string>
#include <vector>
+ Include dependency graph for exception_ctx.hpp:

Go to the source code of this file.

Classes

struct  shambase::args_info
 An argument containing a name and a value. More...
 
struct  shambase::arg_group
 A context group containing a section name and a list of arguments. More...
 
struct  shambase::context
 A context containing a list of argument groups. More...
 

Namespaces

namespace  shambase
 namespace for basic c++ utilities
 

Macros

#define ARG_INFO(var)   shambase::args_info(#var, var)
 Macro to automatically capture variable name and value for exception context.
 

Functions

template<class exception_type >
exception_type shambase::make_except_with_loc_with_ctx (std::string message, context ctx, SourceLocation loc=SourceLocation{})
 Make an exception with a message and variadic context groups.
 

Detailed Description

Provides utilities for adding context to exceptions.

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file exception_ctx.hpp.

Macro Definition Documentation

◆ ARG_INFO

#define ARG_INFO (   var)    shambase::args_info(#var, var)

Macro to automatically capture variable name and value for exception context.

This macro stringifies the variable name and passes both the name and value to create an args_info object.

Example:

int value = 42;
ARG_INFO(value) // Creates args_info("value", 42)
#define ARG_INFO(var)
Macro to automatically capture variable name and value for exception context.

Definition at line 138 of file exception_ctx.hpp.