#pragma once #include namespace DB { class NetException : public Exception { public: template>> NetException(int code, T && message) : Exception(std::forward(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 NetException(int code, FormatStringHelper fmt, Args &&... args) : Exception(fmt::format(fmt.fmt_str, std::forward(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"; } }; }