25 enum class TraceMode {
30 static constexpr size_t kInlineBufferSize = 100;
31 using MemoryBuffer = fmt::basic_memory_buffer<
char, kInlineBufferSize>;
33 TracefulExceptionBase();
35 explicit TracefulExceptionBase(std::string_view what);
37 explicit TracefulExceptionBase(TraceMode trace_mode);
40 virtual ~TracefulExceptionBase() = 0;
42 const MemoryBuffer& MessageBuffer()
const noexcept;
43 const boost::stacktrace::basic_stacktrace<>& Trace()
const noexcept;
46 template <
typename Exception,
typename T>
47 friend typename std::enable_if<
50 operator<<(Exception&& ex,
const T& data) {
51 fmt::format_to(std::back_inserter(ex.GetMessageBuffer()),
"{}", data);
52 ex.EnsureNullTerminated();
53 return std::forward<Exception>(ex);
57 void EnsureNullTerminated();
59 MemoryBuffer& GetMessageBuffer();
62 static constexpr std::size_t kSize =
sizeof(MemoryBuffer) +
compiler::SelectSize().For64Bit(24).For32Bit(12);
63 utils::FastPimpl<Impl, kSize,
alignof(
void*)> impl_;
89std::enable_if_t<std::is_base_of<std::exception, Exception>::value, ExceptionWithAttachedTrace<Exception>>