diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-12-10 13:41:49 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-12-10 13:41:49 -0800 |
commit | 47bc7e93cb03a077c0eef8a2cc871cead1212c00 (patch) | |
tree | 477aa3c5c77a5b458abc19b92c3ca12360c996a5 /cpp/src/Ice/UdpEndpointI.cpp | |
parent | Squashed commit of the following: (diff) | |
download | ice-47bc7e93cb03a077c0eef8a2cc871cead1212c00.tar.bz2 ice-47bc7e93cb03a077c0eef8a2cc871cead1212c00.tar.xz ice-47bc7e93cb03a077c0eef8a2cc871cead1212c00.zip |
bug 4355 - improve parse exception messages
Diffstat (limited to 'cpp/src/Ice/UdpEndpointI.cpp')
-rw-r--r-- | cpp/src/Ice/UdpEndpointI.cpp | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index 6d0ed5e6989..9119ece31f9 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -74,7 +74,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(option[0] != '-') { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw ex; } @@ -89,7 +89,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(end == string::npos) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } else @@ -117,7 +117,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(argument.empty()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "no argument provided for -v option in endpoint `udp " + str + "'"; throw ex; } @@ -125,7 +125,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(pos == string::npos) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "malformed protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } string majorStr = argument.substr(0, pos); @@ -136,7 +136,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(!(majStr >> majVersion) || !majStr.eof()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "invalid protocol major version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } @@ -145,14 +145,14 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(!(minStr >> minVersion) || !minStr.eof()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "invalid protocol minor version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "range error in protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } @@ -174,7 +174,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(argument.empty()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "no argument provided for -e option in endpoint `udp " + str + "'"; throw ex; } string::size_type pos = argument.find('.'); @@ -186,7 +186,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(!(majStr >> majVersion) || !majStr.eof()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "invalid encoding major version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } @@ -195,14 +195,14 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(!(minStr >> minVersion) || !minStr.eof()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "invalid encoding minor version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "range error in encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } @@ -224,18 +224,30 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(argument.empty()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw ex; } const_cast<string&>(_host) = argument; } else if(option == "-p") { + if(argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "no argument provided for -p option in endpoint `udp " + str + "'"; + throw ex; + } istringstream p(argument); - if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535) + if(!(p >> const_cast<Int&>(_port)) || !p.eof()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; + throw ex; + } + else if(_port < 0 || _port > 65535) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw ex; } } @@ -244,7 +256,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(!argument.empty()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw ex; } const_cast<bool&>(_connect) = true; @@ -254,7 +266,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(!argument.empty()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw ex; } const_cast<bool&>(_compress) = true; @@ -264,25 +276,31 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(argument.empty()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw ex; } const_cast<string&>(_mcastInterface) = argument; } else if(option == "--ttl") { + if(argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; + throw ex; + } istringstream p(argument); if(!(p >> const_cast<Int&>(_mcastTtl)) || !p.eof()) { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw ex; } } else { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "unknown option `" + option + "' in `udp " + str + "'"; throw ex; } } @@ -300,7 +318,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin else { EndpointParseException ex(__FILE__, __LINE__); - ex.str = "udp " + str; + ex.str = "`-h *' not valid for proxy endpoint `udp " + str + "'"; throw ex; } } |