mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +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
|
||||
{
|
||||
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;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int DICTIONARY_IS_EMPTY;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user