Packets: extended description of bad_cast exception in Packet.as()
[senf.git] / senf / Socket / Protocols / INet / INet4Address.cc
index 0e56382..79673df 100644 (file)
 #if defined(_REENTRANT) && !defined(__GLIBC__)
 #include <boost/thread/mutex.hpp>
 #endif
+#include <senf/Socket/Protocols/AddressExceptions.hh>
 
 //#include "INet4Address.mpp"
 #define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 
-///////////////////////////////////////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 // senf::INet4Address::INet4Address
 
 prefix_ senf::INet4Address::INet4Address(address_type value)
@@ -51,10 +52,10 @@ prefix_ senf::INet4Address senf::INet4Address::from_string(std::string const & s
 {
     struct in_addr ina;
     if (::inet_pton(AF_INET,s.c_str(),&ina) > 0)
-        return senf::INet4Address::from_inaddr(ina.s_addr);
+        return INet4Address::from_inaddr(ina.s_addr);
 
     if  (s.empty())
-        throw AddressSyntaxException();
+        throw AddressSyntaxException() << ": empty string";
 
     int herr (0);
 
@@ -85,7 +86,7 @@ prefix_ senf::INet4Address senf::INet4Address::from_string(std::string const & s
         throw UnknownHostnameException(s);
 
     // We are only interested in the first address ...
-    return senf::INet4Address::from_inaddr(
+    return INet4Address::from_inaddr(
         reinterpret_cast<in_addr*>(*(ent->h_addr_list))->s_addr);
 }
 
@@ -122,23 +123,23 @@ senf::INet4Address const senf::INet4Address::None;
 senf::INet4Address const senf::INet4Address::Loopback (0x7F000001u);
 senf::INet4Address const senf::INet4Address::Broadcast (0xFFFFFFFFu);
 
-///////////////////////////////////////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 // senf::INet4Network
 
 prefix_ senf::INet4Network::INet4Network(std::string const & s)
 {
     std::string::size_type i (s.find('/'));
     if (i == std::string::npos)
-        throw AddressSyntaxException();
+        throw AddressSyntaxException(s);
     try {
         prefix_len_ = boost::lexical_cast<unsigned>(std::string(s,i+1));
     } catch (boost::bad_lexical_cast const &) {
-        throw AddressSyntaxException();
+        throw AddressSyntaxException(s);
     }
     address_ = INet4Address(INet4Address::from_string(std::string(s, 0, i)).address() & mask());
 }
 
-///////////////////////////////////////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 // namespace members
 
 prefix_ std::ostream & senf::operator<<(std::ostream & os, INet4Address const & addr)
@@ -180,11 +181,11 @@ prefix_ std::istream & senf::operator>>(std::istream & is, INet4Network & addr)
     return is;
 }
 
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 #undef prefix_
 //#include "INet4Address.mpp"
 
-
+\f
 // Local Variables:
 // mode: c++
 // fill-column: 100