From 46f2f8c2962532e010fcb4e3492ce97e2216fb0e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 15 Jan 2009 07:01:02 +0000 Subject: 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. --- src/socket.cpp | 4 ++-- src/tafnode.cpp | 32 ++++++++++++++++++++++++++++---- 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 ) sprintf( ibuf, "%d", nPort ); int ret; - if( ret = DYNLOAD getaddrinfo( sAddr.getStr(), ibuf, &aiHints, &pAddr ) - != 0 ) + if( (ret = DYNLOAD getaddrinfo( + sAddr.getStr(), ibuf, &aiHints, &pAddr )) != 0 ) { #ifdef WIN32 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 const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const { - return hChildren.get( sName ); + try { + return hChildren.get( sName ); + } catch( Bu::HashException &e ) + { + throw Bu::TafException("No children of group \"%s\" match \"%s\".", + this->sName.getStr(), sName.getStr() ); + } } const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const @@ -121,7 +127,13 @@ const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const { - return hChildren.get( sName ).first(); + try { + return hChildren.get( sName ).first(); + } catch( Bu::HashException &e ) + { + throw Bu::TafException("No children of group \"%s\" match \"%s\".", + this->sName.getStr(), sName.getStr() ); + } } bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const @@ -131,12 +143,24 @@ bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const { - return hProp.get( sName ); + try { + return hProp.get( sName ); + } catch( Bu::HashException &e ) + { + throw Bu::TafException("No properties of group \"%s\" match \"%s\".", + this->sName.getStr(), sName.getStr() ); + } } const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const { - return hProp.get( sName ).first(); + try { + return hProp.get( sName ).first(); + } catch( Bu::HashException &e ) + { + throw Bu::TafException("No properties of group \"%s\" match \"%s\".", + this->sName.getStr(), sName.getStr() ); + } } const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName, -- cgit v1.2.3