From c8aa4617a15d7516ffb40205ba85796e31035e20 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Tue, 8 Apr 2008 11:15:12 +0000 Subject: [PATCH] move RepoInfo to universal RepoException. This can enable more verbose output for frontend. (helps with bnc #377137) --- zypp/RepoManager.cc | 8 +++--- zypp/repo/RepoException.cc | 18 +++++++++--- zypp/repo/RepoException.h | 66 ++++++++++++++++---------------------------- zypp/repo/RepoProvideFile.cc | 3 +- 4 files changed, 44 insertions(+), 51 deletions(-) diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index 9f8cbab..d020a95 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -920,7 +920,7 @@ namespace zypp Pathname solvfile = (_pimpl->options.repoCachePath / alias).extend(".solv"); if ( ! PathInfo(solvfile).isExist() ) - ZYPP_THROW(RepoNotCachedException()); + ZYPP_THROW(RepoNotCachedException(info)); try { @@ -1013,7 +1013,7 @@ namespace zypp ++it ) { if ( info.alias() == (*it).alias() ) - ZYPP_THROW(RepoAlreadyExistsException(info.alias())); + ZYPP_THROW(RepoAlreadyExistsException(info)); } RepoInfo tosave = info; @@ -1071,7 +1071,7 @@ namespace zypp if ( (*it).alias() == (*kit).alias() ) { ERR << "To be added repo " << (*it).alias() << " conflicts with existing repo " << (*kit).alias() << endl; - ZYPP_THROW(RepoAlreadyExistsException((*it).alias())); + ZYPP_THROW(RepoAlreadyExistsException(*it)); } } } @@ -1205,7 +1205,7 @@ namespace zypp ++it ) { if ( newinfo.alias() == (*it).alias() ) - ZYPP_THROW(RepoAlreadyExistsException(newinfo.alias())); + ZYPP_THROW(RepoAlreadyExistsException(newinfo)); } } diff --git a/zypp/repo/RepoException.cc b/zypp/repo/RepoException.cc index 9e5d638..5eb845b 100644 --- a/zypp/repo/RepoException.cc +++ b/zypp/repo/RepoException.cc @@ -30,12 +30,22 @@ namespace zypp : Exception( msg_r ) {} - RepoNotCachedException::RepoNotCachedException() - : RepoException( "Repository not Cached" ) + RepoException::RepoException( const RepoInfo & info ) + : Exception( "Repo exception" ), _info( info ) {} - RepoNotCachedException::RepoNotCachedException( const std::string & msg_r ) - : RepoException( 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 ) {} diff --git a/zypp/repo/RepoException.h b/zypp/repo/RepoException.h index d99c1ba..21f0574 100644 --- a/zypp/repo/RepoException.h +++ b/zypp/repo/RepoException.h @@ -35,8 +35,21 @@ namespace zypp RepoException(); /** Ctor */ RepoException( const std::string & msg_r ); + + RepoException( const RepoInfo & info ); + + RepoException( const RepoInfo & info, const std::string & msg_r ); + + virtual ~RepoException() throw() {} + + RepoInfo info() + { return _info; } + protected: virtual std::ostream & dumpOn( std::ostream & str ) const; + + private: + RepoInfo _info; }; /////////////////////////////////////////////////////////////////// @@ -48,8 +61,8 @@ namespace zypp class RepoNotCachedException : public RepoException { public: - RepoNotCachedException(); - RepoNotCachedException( const std::string & msg_r ); + RepoNotCachedException( const RepoInfo& info ); + RepoNotCachedException( const RepoInfo& info, const std::string & msg_r ); }; /** @@ -63,16 +76,9 @@ namespace zypp {} RepoNoUrlException( const RepoInfo &info) - : _info(info) - {} + : RepoException(info) + {} - ~RepoNoUrlException() throw() - {} - - RepoInfo info() - { return _info; } - private: - RepoInfo _info; }; /** @@ -92,15 +98,8 @@ namespace zypp { public: RepoNotFoundException( const RepoInfo &info) - : _info(info) - {} - ~RepoNotFoundException() throw() + : RepoException(info) {} - - RepoInfo info() - { return _info; } - private: - RepoInfo _info; }; /** @@ -110,24 +109,17 @@ namespace zypp class RepoAlreadyExistsException : public RepoException { public: - ~RepoAlreadyExistsException() throw() - {} - - RepoAlreadyExistsException( const std::string &alias, + RepoAlreadyExistsException( const RepoInfo &info, const std::string & msg_r ) - : RepoException(msg_r) - , _alias(alias) + : RepoException(info,msg_r) {} - RepoAlreadyExistsException( const std::string &alias ) - : _alias(alias) + RepoAlreadyExistsException( const RepoInfo &info ) + : RepoException(info) {} std::string alias() - { return _alias; } - - private: - std::string _alias; + { return info().alias(); } }; /** @@ -144,8 +136,6 @@ namespace zypp RepoUnknownTypeException() {} - ~RepoUnknownTypeException() throw() - {} }; /** @@ -156,19 +146,11 @@ namespace zypp { public: RepoMetadataException( const RepoInfo &info) - : _info(info) + : RepoException(info) {} RepoMetadataException() {} - - ~RepoMetadataException() throw() - {} - - RepoInfo info() - { return _info; } - private: - RepoInfo _info; }; ///////////////////////////////////////////////////////////////// diff --git a/zypp/repo/RepoProvideFile.cc b/zypp/repo/RepoProvideFile.cc index ecb3539..7439a5d 100644 --- a/zypp/repo/RepoProvideFile.cc +++ b/zypp/repo/RepoProvideFile.cc @@ -212,7 +212,8 @@ namespace zypp Url url; - RepoException repo_excpt(str::form(_("Can't provide file '%s' from repository '%s'"), + RepoException repo_excpt(repo_r, + str::form(_("Can't provide file '%s' from repository '%s'"), loc_r.filename().c_str(), repo_r.alias().c_str() ) ); -- 2.7.4