[zypp-commit] r11613 - in /trunk/libzypp/zypp: RepoInfo.h repo/RepoException.cc repo/RepoException.h
Author: mlandres Date: Thu Nov 6 22:17:41 2008 New Revision: 11613 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11613&view=rev Log: Unify RepoExceptions Modified: trunk/libzypp/zypp/RepoInfo.h trunk/libzypp/zypp/repo/RepoException.cc trunk/libzypp/zypp/repo/RepoException.h Modified: trunk/libzypp/zypp/RepoInfo.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoInfo.h?rev=11613&r1=11612&r2=11613&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoInfo.h (original) +++ trunk/libzypp/zypp/RepoInfo.h Thu Nov 6 22:17:41 2008 @@ -111,6 +111,11 @@ */ urls_const_iterator baseUrlsEnd() const; /** + * Pars pro toto: The first repository url + */ + Url url() const + { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); } + /** * A Url under which the metadata are located, or a set of mirrors. * * This can't be empty in order the repository to be valid Modified: trunk/libzypp/zypp/repo/RepoException.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/RepoException.cc?rev=11613&r1=11612&r2=11613&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/RepoException.cc (original) +++ trunk/libzypp/zypp/repo/RepoException.cc Thu Nov 6 22:17:41 2008 @@ -10,7 +10,6 @@ * */ #include <iostream> -//#include "zypp/base/Logger.h" #include "zypp/repo/RepoException.h" #include "zypp/base/String.h" @@ -41,31 +40,38 @@ : Exception( "Repo exception" ), _info( info ) {} - RepoException::RepoException( const RepoInfo & info, - const std::string& msg_r ) + RepoException::RepoException( const RepoInfo & info, const std::string& msg_r ) : Exception( msg_r ), _info( info ) {} - RepoNotCachedException::RepoNotCachedException( const RepoInfo& info ) - : RepoException( info, "Repository not Cached" ) - {} - - RepoNotCachedException::RepoNotCachedException( const RepoInfo& info, - const std::string & msg_r ) - : RepoException( info, msg_r ) - {} - - RepoUnknownTypeException::RepoUnknownTypeException( const RepoInfo &info) - : RepoException( info, - str::form("Cannot determine type for repository %s.",info.alias().c_str())) + RepoException::~RepoException() throw() {} std::ostream & RepoException::dumpOn( std::ostream & str ) const { + str << "[" << _info.alias() << "|" << _info.url() << "] "; return Exception::dumpOn( str ); } /////////////////////////////////////////////////////////////////// + +#define DEF_CTORS( CLASS, MSG ) \ + CLASS::CLASS() : RepoException( MSG ) {} \ + CLASS::CLASS( const std::string & msg_r ) : RepoException( msg_r ) {} \ + CLASS::CLASS( const RepoInfo & service_r ) : RepoException( service_r, MSG ) {} \ + CLASS::CLASS( const RepoInfo & service_r, const std::string & msg_r ) : RepoException( service_r, msg_r ) {} + + DEF_CTORS( RepoNotCachedException, "Repository is not cached" ); + DEF_CTORS( RepoNoUrlException, "Repository has no or invalid url defined." ); + DEF_CTORS( RepoNoAliasException, "Repository has no alias defined." ); + DEF_CTORS( RepoNotFoundException, "Repository not found." ); + DEF_CTORS( RepoAlreadyExistsException, "Repository already exists." ); + DEF_CTORS( RepoUnknownTypeException, "Repository type can't be determined." ); + DEF_CTORS( RepoMetadataException, "Repository metadata not usable." ); + +#undef DEF_CTORS + + /////////////////////////////////////////////////////////////////// // // Service related exceptions // Modified: trunk/libzypp/zypp/repo/RepoException.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/RepoException.h?rev=11613&r1=11612&r2=11613&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/RepoException.h (original) +++ trunk/libzypp/zypp/repo/RepoException.h Thu Nov 6 22:17:41 2008 @@ -36,26 +36,24 @@ */ class RepoException : public Exception { - public: - /** Default ctor */ - RepoException(); - /** Ctor */ - RepoException( const std::string & msg_r ); - - RepoException( const RepoInfo & info ); - - RepoException( const RepoInfo & info, const std::string & msg_r ); + public: + RepoException(); + RepoException( const std::string & msg_r ); + RepoException( const RepoInfo & info ); + RepoException( const RepoInfo & info, const std::string & msg_r ); + virtual ~RepoException() throw(); - virtual ~RepoException() throw() {} + RepoInfo info() + { return _info; } - RepoInfo info() - { return _info; } + std::string alias() + { return info().alias(); } - protected: - virtual std::ostream & dumpOn( std::ostream & str ) const; + protected: + virtual std::ostream & dumpOn( std::ostream & str ) const; - private: - RepoInfo _info; + private: + RepoInfo _info; }; /////////////////////////////////////////////////////////////////// @@ -66,9 +64,11 @@ */ class RepoNotCachedException : public RepoException { - public: - RepoNotCachedException( const RepoInfo& info ); - RepoNotCachedException( const RepoInfo& info, const std::string & msg_r ); + public: + RepoNotCachedException(); + RepoNotCachedException( const std::string & msg_r ); + RepoNotCachedException( const RepoInfo & info ); + RepoNotCachedException( const RepoInfo & info, const std::string & msg_r ); }; /** @@ -78,13 +78,10 @@ class RepoNoUrlException : public RepoException { public: - RepoNoUrlException() - {} - - RepoNoUrlException( const RepoInfo &info) - : RepoException(info) - {} - + RepoNoUrlException(); + RepoNoUrlException( const std::string & msg_r ); + RepoNoUrlException( const RepoInfo & info ); + RepoNoUrlException( const RepoInfo & info, const std::string & msg_r ); }; /** @@ -93,7 +90,11 @@ */ class RepoNoAliasException : public RepoException { - + public: + RepoNoAliasException(); + RepoNoAliasException( const std::string & msg_r ); + RepoNoAliasException( const RepoInfo & info ); + RepoNoAliasException( const RepoInfo & info, const std::string & msg_r ); }; /** @@ -102,10 +103,11 @@ */ class RepoNotFoundException : public RepoException { - public: - RepoNotFoundException( const RepoInfo &info) - : RepoException(info) - {} + public: + RepoNotFoundException(); + RepoNotFoundException( const std::string & msg_r ); + RepoNotFoundException( const RepoInfo & info ); + RepoNotFoundException( const RepoInfo & info, const std::string & msg_r ); }; /** @@ -114,18 +116,11 @@ */ class RepoAlreadyExistsException : public RepoException { - public: - RepoAlreadyExistsException( const RepoInfo &info, - const std::string & msg_r ) - : RepoException(info,msg_r) - {} - - RepoAlreadyExistsException( const RepoInfo &info ) - : RepoException(info) - {} - - std::string alias() - { return info().alias(); } + public: + RepoAlreadyExistsException(); + RepoAlreadyExistsException( const std::string & msg_r ); + RepoAlreadyExistsException( const RepoInfo & info ); + RepoAlreadyExistsException( const RepoInfo & info, const std::string & msg_r ); }; /** @@ -134,16 +129,11 @@ */ class RepoUnknownTypeException : public RepoException { - public: - RepoUnknownTypeException( const std::string & msg_r ) - : RepoException(msg_r) - {} - - RepoUnknownTypeException( const RepoInfo &info ); - - RepoUnknownTypeException() - {} - + public: + RepoUnknownTypeException(); + RepoUnknownTypeException( const std::string & msg_r ); + RepoUnknownTypeException( const RepoInfo & info ); + RepoUnknownTypeException( const RepoInfo & info, const std::string & msg_r ); }; /** @@ -152,13 +142,11 @@ */ class RepoMetadataException : public RepoException { - public: - RepoMetadataException( const RepoInfo &info) - : RepoException(info) - {} - - RepoMetadataException() - {} + public: + RepoMetadataException(); + RepoMetadataException( const std::string & msg_r ); + RepoMetadataException( const RepoInfo & info ); + RepoMetadataException( const RepoInfo & info, const std::string & msg_r ); }; //@} @@ -184,7 +172,10 @@ ServiceInfo service() { return _service; } - protected: + std::string alias() + { return service().alias(); } + + protected: virtual std::ostream & dumpOn( std::ostream & str ) const; private: -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
mlandres@svn.opensuse.org