Bash++
Bash++ compiler internal documentation
InternalError.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Andrew S. Rightenburg
3 * Bash++: Bash with classes
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7#pragma once
8
9#include <stdexcept>
10
12
21struct InternalError : public std::runtime_error {
22 explicit InternalError(const std::string& msg)
23 : std::runtime_error(msg + "\nYou've found a bug! Please report it.") {}
24
25 InternalError(const std::string& msg, const std::string& file, int line)
26 : std::runtime_error(msg + "\nYou've found a bug! Please report it.\nAt " + file + ":" + std::to_string(line)) {}
27};
28
29} // namespace bpp::ErrorHandling
30
31#if !defined (NDEBUG)
32 #define bpp_assert(expr, msg) \
33 do { \
34 if (!(expr)) { \
35 throw bpp::ErrorHandling::InternalError(msg, __FILE__, __LINE__); \
36 } \
37 } while (false)
38#else
39 #define bpp_assert(expr, msg) ((void)0)
40#endif
Definition InternalError.h:11
An exception thrown when an internal error occurs.
Definition InternalError.h:21
InternalError(const std::string &msg)
Definition InternalError.h:22
InternalError(const std::string &msg, const std::string &file, int line)
Definition InternalError.h:25