blob: e4945d88d1a41f5ddcf8b31b554f892313dfcd30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "config.h"
#include "exception.h"
#include <cassert>
#include <string>
EaxException::EaxException(std::string_view context, std::string_view message)
: std::runtime_error{make_message(context, message)}
{
}
EaxException::~EaxException() = default;
std::string EaxException::make_message(std::string_view context, std::string_view message)
{
auto what = std::string{};
if(context.empty() && message.empty())
return what;
what.reserve((!context.empty() ? context.size() + 3 : 0) + message.length() + 1);
if(!context.empty())
{
what += "[";
what += context;
what += "] ";
}
what += message;
return what;
}
|