9 EaxException::EaxException(const char *context
, const char *message
)
10 : std::runtime_error
{make_message(context
, message
)}
13 EaxException::~EaxException() = default;
16 std::string
EaxException::make_message(const char *context
, const char *message
)
18 const auto context_size
= (context
? std::string::traits_type::length(context
) : 0);
19 const auto has_contex
= (context_size
> 0);
21 const auto message_size
= (message
? std::string::traits_type::length(message
) : 0);
22 const auto has_message
= (message_size
> 0);
24 if (!has_contex
&& !has_message
)
29 static constexpr char left_prefix
[] = "[";
30 const auto left_prefix_size
= std::string::traits_type::length(left_prefix
);
32 static constexpr char right_prefix
[] = "] ";
33 const auto right_prefix_size
= std::string::traits_type::length(right_prefix
);
35 const auto what_size
=
38 left_prefix_size
+ context_size
+ right_prefix_size
:
43 auto what
= std::string
{};
44 what
.reserve(what_size
);
48 what
.append(left_prefix
, left_prefix_size
);
49 what
.append(context
, context_size
);
50 what
.append(right_prefix
, right_prefix_size
);
55 what
.append(message
, message_size
);