未验证 提交 6ce3bd69 编写于 作者: A alexey-milovidov 提交者: GitHub

Merge pull request #18548 from vdimir/fix-ip-dict-exception

Do not throw logical error from IPAddressDictionary ctor
......@@ -21,10 +21,12 @@ namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int TYPE_MISMATCH;
extern const int BAD_ARGUMENTS;
extern const int CANNOT_PARSE_INPUT_ASSERTION_FAILED;
extern const int CANNOT_PARSE_NUMBER;
extern const int DICTIONARY_IS_EMPTY;
extern const int LOGICAL_ERROR;
extern const int TYPE_MISMATCH;
}
namespace
......@@ -89,9 +91,9 @@ static std::pair<Poco::Net::IPAddress, UInt8> parseIPFromString(const std::strin
const auto * addr_str_end = addr_str.data() + addr_str.size();
auto [p, ec] = std::from_chars(addr_str.data() + pos + 1, addr_str_end, prefix);
if (p != addr_str_end)
throw DB::Exception("extra characters at the end", ErrorCodes::LOGICAL_ERROR);
throw DB::Exception("Extra characters at the end of IP address", ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED);
if (ec != std::errc())
throw DB::Exception("mask is not a valid number", ErrorCodes::LOGICAL_ERROR);
throw DB::Exception("Mask for IP address is not a valid number", ErrorCodes::CANNOT_PARSE_NUMBER);
addr = addr & Poco::Net::IPAddress(prefix, addr.family());
return {addr, prefix};
......@@ -102,8 +104,8 @@ static std::pair<Poco::Net::IPAddress, UInt8> parseIPFromString(const std::strin
}
catch (Poco::Exception & ex)
{
throw DB::Exception("can't parse address \"" + std::string(addr_str) + "\": " + ex.what(),
ErrorCodes::LOGICAL_ERROR);
throw DB::Exception("Can't parse address \"" + std::string(addr_str) + "\": " + ex.what(),
ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册