Line data Source code
1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Declares function abort_with_error_message 6 : 7 : #pragma once 8 : 9 : #include <string> 10 : 11 : /// \ingroup ErrorHandlingGroup 12 : /// Compose an error message with an expression and a backtrace, then abort the 13 : /// program. 14 : /// 15 : /// We try to demangle and format the backtrace. Long symbol names are 16 : /// abbreviated, unless you set the `SPECTRE_SHOW_FULL_BACKTRACE_SYMBOLS` 17 : /// environment variable to a non-empty value (e.g. "1"). 18 1 : [[noreturn]] void abort_with_error_message(const char* expression, 19 : const char* file, int line, 20 : const char* pretty_function, 21 : const std::string& message); 22 : 23 : /// \ingroup ErrorHandlingGroup 24 : /// Compose an error message including a backtrace and abort the program. 25 : /// 26 : /// We try to demangle and format the backtrace. Long symbol names are 27 : /// abbreviated, unless you set the `SPECTRE_SHOW_FULL_BACKTRACE_SYMBOLS` 28 : /// environment variable to a non-empty value (e.g. "1"). 29 : template <typename ExceptionTypeToThrow> 30 1 : [[noreturn]] void abort_with_error_message(const char* file, int line, 31 : const char* pretty_function, 32 : const std::string& message); 33 : 34 : /// \ingroup ErrorHandlingGroup 35 : /// Compose an error message without a backtrace and abort the program. 36 : /// 37 : /// \note This always throws `SpectreError` as the exception type. 38 1 : [[noreturn]] void abort_with_error_message_no_trace(const char* file, int line, 39 : const char* pretty_function, 40 : const std::string& message);