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
33
34
35
36
37
38
39
|
#pragma once
#include <Common/Exception.h>
namespace DB
{
class NetException : public Exception
{
public:
template <typename T>
requires std::is_convertible_v<T, String>
NetException(int code, T && message) : Exception(std::forward<T>(message), code)
{
message_format_string = tryGetStaticFormatString(message);
}
template<> NetException(int code, const String & message) : Exception(message, code) {}
template<> NetException(int code, String & message) : Exception(message, code) {}
template<> NetException(int code, String && message) : Exception(std::move(message), code) {}
// Format message with fmt::format, like the logging functions.
template <typename... Args>
NetException(int code, FormatStringHelper<Args...> fmt, Args &&... args)
: Exception(fmt::format(fmt.fmt_str, std::forward<Args>(args)...), code)
{
message_format_string = fmt.message_format_string;
}
NetException * clone() const override { return new NetException(*this); }
void rethrow() const override { throw *this; }
private:
const char * name() const noexcept override { return "DB::NetException"; }
const char * className() const noexcept override { return "DB::NetException"; }
};
}
|