mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
final fix
This commit is contained in:
parent
a9bd177b2e
commit
6f30fae34e
@ -450,5 +450,49 @@ ExecutionStatus ExecutionStatus::fromCurrentException(const std::string & start_
|
||||
return ExecutionStatus(getCurrentExceptionCode(), msg);
|
||||
}
|
||||
|
||||
ParsingException::ParsingException()
|
||||
{
|
||||
Exception::message(Exception::message() + "{}");
|
||||
}
|
||||
|
||||
ParsingException::ParsingException(const std::string & msg, int code)
|
||||
: Exception(msg, code)
|
||||
{
|
||||
Exception::message(Exception::message() + "{}");
|
||||
}
|
||||
|
||||
ParsingException::ParsingException(int code, const std::string & message)
|
||||
: Exception(message, code)
|
||||
{
|
||||
Exception::message(Exception::message() + "{}");
|
||||
}
|
||||
|
||||
|
||||
/// We use additional field formatted_message_ to make this method const.
|
||||
std::string ParsingException::displayText() const
|
||||
{
|
||||
try
|
||||
{
|
||||
if (line_number_ == -1)
|
||||
formatted_message_ = fmt::format(message(), "");
|
||||
else
|
||||
formatted_message_ = fmt::format(message(), fmt::format(": (at row {})\n", line_number_));
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
if (!formatted_message_.empty())
|
||||
{
|
||||
std::string result = name();
|
||||
result.append(": ");
|
||||
result.append(formatted_message_);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Exception::displayText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -101,50 +101,20 @@ private:
|
||||
class ParsingException : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
ParsingException();
|
||||
ParsingException(const std::string & msg, int code);
|
||||
ParsingException(int code, const std::string & message);
|
||||
|
||||
ParsingException()
|
||||
// Format message with fmt::format, like the logging functions.
|
||||
template <typename ...Args>
|
||||
ParsingException(int code, const std::string & fmt, Args&&... args)
|
||||
: Exception(fmt::format(fmt, std::forward<Args>(args)...), code)
|
||||
{
|
||||
Exception::addMessage("{}");
|
||||
Exception::message(Exception::message() + "{}");
|
||||
}
|
||||
|
||||
ParsingException(const std::string & msg, int code)
|
||||
: Exception(msg, code)
|
||||
{
|
||||
Exception::addMessage("{}");
|
||||
}
|
||||
|
||||
ParsingException(int code, const std::string & message)
|
||||
: Exception(message, code)
|
||||
{
|
||||
Exception::addMessage("{}");
|
||||
}
|
||||
|
||||
/// We use additional field formatted_message_ to make this method const.
|
||||
std::string displayText() const override
|
||||
{
|
||||
try
|
||||
{
|
||||
if (line_number_ == -1)
|
||||
formatted_message_ = fmt::format(message(), "");
|
||||
else
|
||||
formatted_message_ = fmt::format(message(), fmt::format("(at row {})\n", line_number_));
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
if (!formatted_message_.empty())
|
||||
{
|
||||
std::string result = name();
|
||||
result.append(": ");
|
||||
result.append(formatted_message_);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Exception::displayText();
|
||||
}
|
||||
}
|
||||
std::string displayText() const override;
|
||||
|
||||
int getLineNumber() { return line_number_; }
|
||||
void setLineNumber(int line_number) { line_number_ = line_number;}
|
||||
|
Loading…
Reference in New Issue
Block a user