diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2017-08-17 14:36:18 -0400 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2017-08-18 17:45:19 -0400 |
commit | 068fcc78763801bb6812981f0988a6e01c14376d (patch) | |
tree | b2ff53c1413548961fbf24e69327747169bbae65 /src/mongo/util/net/cidr.cpp | |
parent | f87acd46f9445939e3c8e0531380a7870eff2b1f (diff) | |
download | mongo-068fcc78763801bb6812981f0988a6e01c14376d.tar.gz |
SERVER-30721 Remove CIDRException, use DBException directly
Diffstat (limited to 'src/mongo/util/net/cidr.cpp')
-rw-r--r-- | src/mongo/util/net/cidr.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/util/net/cidr.cpp b/src/mongo/util/net/cidr.cpp index d8fe660eb23..11de75bb7de 100644 --- a/src/mongo/util/net/cidr.cpp +++ b/src/mongo/util/net/cidr.cpp @@ -96,8 +96,8 @@ StatusWith<CIDR> CIDR::parse(BSONElement from) noexcept { StatusWith<CIDR> CIDR::parse(StringData s) noexcept try { return CIDR(s); -} catch (const CIDRException& e) { - return {ErrorCodes::UnsupportedFormat, e.what()}; +} catch (const DBException& e) { + return e.toStatus(); } CIDR::CIDR(StringData s) try { @@ -111,7 +111,7 @@ CIDR::CIDR(StringData s) try { _family = AF_INET6; _len = kIPv6Bits; } else { - throw CIDRException("Invalid IP address in CIDR string"); + uasserted(ErrorCodes::UnsupportedFormat, "Invalid IP address in CIDR string"); } if (slash == end(s)) { @@ -119,15 +119,15 @@ CIDR::CIDR(StringData s) try { } auto len = strict_stoi(std::string(slash + 1, end(s)), 10); - if ((len < 0) || (len > _len)) { - throw CIDRException("Invalid length in CIDR string"); - } + uassert(ErrorCodes::UnsupportedFormat, + "Invalid length in CIDR string", + (len >= 0) && (len <= _len)); _len = len; } catch (const std::invalid_argument& e) { - throw CIDRException("Non-numeric length in CIDR string"); + uasserted(ErrorCodes::UnsupportedFormat, "Non-numeric length in CIDR string"); } catch (const std::out_of_range& e) { - throw CIDRException("Invalid length in CIDR string"); + uasserted(ErrorCodes::UnsupportedFormat, "Invalid length in CIDR string"); } template <> |