summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-15 07:01:02 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-15 07:01:02 +0000
commit46f2f8c2962532e010fcb4e3492ce97e2216fb0e (patch)
tree4b8b04bb10484e0bc23845d332a518455bcdbbc1 /src
parent422a09d330d15f90c854dcc1001a544ffd4b4967 (diff)
downloadlibbu++-46f2f8c2962532e010fcb4e3492ce97e2216fb0e.tar.gz
libbu++-46f2f8c2962532e010fcb4e3492ce97e2216fb0e.tar.bz2
libbu++-46f2f8c2962532e010fcb4e3492ce97e2216fb0e.tar.xz
libbu++-46f2f8c2962532e010fcb4e3492ce97e2216fb0e.zip
Fixed a minor suggestion in Bu::Socket, gcc wanted more parenthesies to make a
statement clearer (good coding guide). Made the Taf code getters report their own errors, so much nicer. They actually tell you what was looked for from where and that it couldn't be found instead of a horrible old Bu::HashException key not found error.
Diffstat (limited to 'src')
-rw-r--r--src/socket.cpp4
-rw-r--r--src/tafnode.cpp32
2 files changed, 30 insertions, 6 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index c93ec6e..c57d97e 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -89,8 +89,8 @@ Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout )
89 sprintf( ibuf, "%d", nPort ); 89 sprintf( ibuf, "%d", nPort );
90 90
91 int ret; 91 int ret;
92 if( ret = DYNLOAD getaddrinfo( sAddr.getStr(), ibuf, &aiHints, &pAddr ) 92 if( (ret = DYNLOAD getaddrinfo(
93 != 0 ) 93 sAddr.getStr(), ibuf, &aiHints, &pAddr )) != 0 )
94 { 94 {
95 #ifdef WIN32 95 #ifdef WIN32
96 throw Bu::SocketException("Couldn't resolve hostname %s (%d).\n", 96 throw Bu::SocketException("Couldn't resolve hostname %s (%d).\n",
diff --git a/src/tafnode.cpp b/src/tafnode.cpp
index 829a8e1..09fc21b 100644
--- a/src/tafnode.cpp
+++ b/src/tafnode.cpp
@@ -111,7 +111,13 @@ bool Bu::TafGroup::hasChild( const Bu::FString &sName ) const
111 111
112const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const 112const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const
113{ 113{
114 return hChildren.get( sName ); 114 try {
115 return hChildren.get( sName );
116 } catch( Bu::HashException &e )
117 {
118 throw Bu::TafException("No children of group \"%s\" match \"%s\".",
119 this->sName.getStr(), sName.getStr() );
120 }
115} 121}
116 122
117const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const 123const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const
@@ -121,7 +127,13 @@ const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const
121 127
122const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const 128const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const
123{ 129{
124 return hChildren.get( sName ).first(); 130 try {
131 return hChildren.get( sName ).first();
132 } catch( Bu::HashException &e )
133 {
134 throw Bu::TafException("No children of group \"%s\" match \"%s\".",
135 this->sName.getStr(), sName.getStr() );
136 }
125} 137}
126 138
127bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const 139bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const
@@ -131,12 +143,24 @@ bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const
131 143
132const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const 144const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const
133{ 145{
134 return hProp.get( sName ); 146 try {
147 return hProp.get( sName );
148 } catch( Bu::HashException &e )
149 {
150 throw Bu::TafException("No properties of group \"%s\" match \"%s\".",
151 this->sName.getStr(), sName.getStr() );
152 }
135} 153}
136 154
137const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const 155const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const
138{ 156{
139 return hProp.get( sName ).first(); 157 try {
158 return hProp.get( sName ).first();
159 } catch( Bu::HashException &e )
160 {
161 throw Bu::TafException("No properties of group \"%s\" match \"%s\".",
162 this->sName.getStr(), sName.getStr() );
163 }
140} 164}
141 165
142const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName, 166const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName,