mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #18548 from vdimir/fix-ip-dict-exception
Do not throw logical error from IPAddressDictionary ctor
This commit is contained in:
commit
6ce3bd6962
@ -21,10 +21,12 @@ namespace DB
|
|||||||
{
|
{
|
||||||
namespace ErrorCodes
|
namespace ErrorCodes
|
||||||
{
|
{
|
||||||
|
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 LOGICAL_ERROR;
|
||||||
extern const int TYPE_MISMATCH;
|
extern const int TYPE_MISMATCH;
|
||||||
extern const int BAD_ARGUMENTS;
|
|
||||||
extern const int DICTIONARY_IS_EMPTY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
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();
|
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);
|
auto [p, ec] = std::from_chars(addr_str.data() + pos + 1, addr_str_end, prefix);
|
||||||
if (p != addr_str_end)
|
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())
|
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());
|
addr = addr & Poco::Net::IPAddress(prefix, addr.family());
|
||||||
return {addr, prefix};
|
return {addr, prefix};
|
||||||
@ -102,8 +104,8 @@ static std::pair<Poco::Net::IPAddress, UInt8> parseIPFromString(const std::strin
|
|||||||
}
|
}
|
||||||
catch (Poco::Exception & ex)
|
catch (Poco::Exception & ex)
|
||||||
{
|
{
|
||||||
throw DB::Exception("can't parse address \"" + std::string(addr_str) + "\": " + ex.what(),
|
throw DB::Exception("Can't parse address \"" + std::string(addr_str) + "\": " + ex.what(),
|
||||||
ErrorCodes::LOGICAL_ERROR);
|
ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user