3 #include "eax_exception.h"
10 EaxException::EaxException(
14 std::runtime_error
{make_message(context
, message
)}
18 std::string
EaxException::make_message(
22 const auto context_size
= (context
? std::string::traits_type::length(context
) : 0);
23 const auto has_contex
= (context_size
> 0);
25 const auto message_size
= (message
? std::string::traits_type::length(message
) : 0);
26 const auto has_message
= (message_size
> 0);
28 if (!has_contex
&& !has_message
)
33 static constexpr char left_prefix
[] = "[";
34 const auto left_prefix_size
= std::string::traits_type::length(left_prefix
);
36 static constexpr char right_prefix
[] = "] ";
37 const auto right_prefix_size
= std::string::traits_type::length(right_prefix
);
39 const auto what_size
=
42 left_prefix_size
+ context_size
+ right_prefix_size
:
47 auto what
= std::string
{};
48 what
.reserve(what_size
);
52 what
.append(left_prefix
, left_prefix_size
);
53 what
.append(context
, context_size
);
54 what
.append(right_prefix
, right_prefix_size
);
59 what
.append(message
, message_size
);