9 EaxException::EaxException(
13 std::runtime_error
{make_message(context
, message
)}
17 std::string
EaxException::make_message(
21 const auto context_size
= (context
? std::string::traits_type::length(context
) : 0);
22 const auto has_contex
= (context_size
> 0);
24 const auto message_size
= (message
? std::string::traits_type::length(message
) : 0);
25 const auto has_message
= (message_size
> 0);
27 if (!has_contex
&& !has_message
)
32 static constexpr char left_prefix
[] = "[";
33 const auto left_prefix_size
= std::string::traits_type::length(left_prefix
);
35 static constexpr char right_prefix
[] = "] ";
36 const auto right_prefix_size
= std::string::traits_type::length(right_prefix
);
38 const auto what_size
=
41 left_prefix_size
+ context_size
+ right_prefix_size
:
46 auto what
= std::string
{};
47 what
.reserve(what_size
);
51 what
.append(left_prefix
, left_prefix_size
);
52 what
.append(context
, context_size
);
53 what
.append(right_prefix
, right_prefix_size
);
58 what
.append(message
, message_size
);