From af06f4de8de03b02e0ed9bc007b94a60c0291e7a Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Wed, 12 Sep 2007 15:57:05 +0000 Subject: [PATCH] better handling of exceptions here, remembering all errors. --- zypp/repo/RepoException.h | 16 +++++++++++++++- zypp/repo/RepoProvideFile.cc | 25 +++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/zypp/repo/RepoException.h b/zypp/repo/RepoException.h index ab8c6f1..d99c1ba 100644 --- a/zypp/repo/RepoException.h +++ b/zypp/repo/RepoException.h @@ -58,7 +58,21 @@ namespace zypp */ class RepoNoUrlException : public RepoException { - + public: + RepoNoUrlException() + {} + + RepoNoUrlException( const RepoInfo &info) + : _info(info) + {} + + ~RepoNoUrlException() throw() + {} + + RepoInfo info() + { return _info; } + private: + RepoInfo _info; }; /** diff --git a/zypp/repo/RepoProvideFile.cc b/zypp/repo/RepoProvideFile.cc index 1d7e137..29cd828 100644 --- a/zypp/repo/RepoProvideFile.cc +++ b/zypp/repo/RepoProvideFile.cc @@ -191,7 +191,7 @@ namespace zypp const OnMediaLocation & loc_r, const ProvideFilePolicy & policy_r ) { - MIL << "provideFile " << loc_r << endl; + MIL << loc_r << endl; // Arrange DownloadFileReportHack to recieve the source::DownloadFileReport // and redirect download progress triggers to call the ProvideFilePolicy // callback. @@ -202,14 +202,23 @@ namespace zypp Url url; RepoInfo info = repo_r.info(); + + RepoException repo_excpt(str::form(_("Can't provide file %s from repository %s"), + loc_r.filename().c_str(), + info.alias().c_str() ) ); + if ( info.baseUrlsEmpty() ) - ZYPP_THROW(Exception(_("No url in repository."))); - + { + repo_excpt.remember(RepoException(_("No url in repository."))); + ZYPP_THROW(repo_excpt); + } + for ( RepoInfo::urls_const_iterator it = info.baseUrlsBegin(); it != info.baseUrlsEnd(); - ++it ) + /* incremented in the loop */ ) { url = *it; + ++it; try { MIL << "Providing file of repo '" << info.alias() @@ -270,15 +279,15 @@ namespace zypp catch ( const Exception &e ) { ZYPP_CAUGHT( e ); + + repo_excpt.remember(e); + WAR << "Trying next url" << endl; continue; } } // iteration over urls - ZYPP_THROW(Exception(str::form(_("Can't provide file %s from repository %s"), - loc_r.filename().c_str(), - info.alias().c_str() ) ) ); - + ZYPP_THROW(repo_excpt); return ManagedFile(); // not reached } -- 2.7.4