26 enum class TraceMode {
31 static constexpr size_t kInlineBufferSize = 100;
32 using MemoryBuffer = fmt::basic_memory_buffer<
char, kInlineBufferSize>;
34 TracefulExceptionBase();
36 explicit TracefulExceptionBase(std::string_view what);
38 explicit TracefulExceptionBase(TraceMode trace_mode);
41 virtual ~TracefulExceptionBase() = 0;
43 const MemoryBuffer& MessageBuffer()
const noexcept;
44 const boost::stacktrace::basic_stacktrace<>& Trace()
const noexcept;
47 template <
typename Exception,
typename T>
48 friend typename std::enable_if<
51 operator<<(Exception&& ex,
const T& data) {
52 fmt::format_to(std::back_inserter(ex.GetMessageBuffer()),
"{}", data);
53 ex.EnsureNullTerminated();
54 return std::forward<Exception>(ex);
58 void EnsureNullTerminated();
60 MemoryBuffer& GetMessageBuffer();
63 static constexpr std::size_t kSize =
sizeof(MemoryBuffer) +
compiler::SelectSize().For64Bit(24).For32Bit(12);
64 utils::FastPimpl<Impl, kSize,
alignof(
void*)> impl_;
92std::enable_if_t<std::is_base_of<std::exception, Exception>::value, ExceptionWithAttachedTrace<Exception>>