mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
70d1adfe4b
* save format string for NetException * format exceptions * format exceptions 2 * format exceptions 3 * format exceptions 4 * format exceptions 5 * format exceptions 6 * fix * format exceptions 7 * format exceptions 8 * Update MergeTreeIndexGin.cpp * Update AggregateFunctionMap.cpp * Update AggregateFunctionMap.cpp * fix
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <Common/Exception.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class NetException : public Exception
|
|
{
|
|
public:
|
|
template<typename T, typename = std::enable_if_t<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"; }
|
|
};
|
|
|
|
}
|