Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
exception.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
20#include <string>
21
22namespace shambase {
23
25 return loc.format_multiline(fmt_callstack());
26 }
27
29 void (*exception_print_callback)(std::string msg) = nullptr;
30
31 void exception_gen_callback(std::string msg) {
32 if (exception_print_callback != nullptr) {
34 }
35 }
36
40
42
43} // namespace shambase
Source location utility.
This header file contains utility functions related to exception handling in the code.
namespace for basic c++ utilities
std::string fmt_callstack()
Get the formatted callstack.
void set_exception_gen_callback(exception_gen_callback_t callback)
Set the exception generator callback.
Definition exception.cpp:37
std::string exception_format(SourceLocation loc)
Format the exception message with the source location information.
Definition exception.cpp:24
void(*)(std::string msg) exception_gen_callback_t
type of the exception generator callback
Definition exception.hpp:42
void(* exception_print_callback)(std::string msg)
exception print callback func ptr
Definition exception.cpp:29
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
void exception_gen_callback(std::string msg)
The callback called when an exception is thrown.
Definition exception.cpp:31
exception_gen_callback_t get_exception_gen_callback()
Get the current exception generator callback.
Definition exception.cpp:41
This file contains the definition for the stacktrace related functionality.
provide information about the source location
std::string format_multiline() const
format the location in multiple lines