*/
#include <iostream>
#include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
#include "zypp/ZYpp.h"
#include "zypp/ZYppFactory.h"
bool SourceManager::restore(Pathname root_r, bool use_caches )
{
if (! _sources.empty() )
- ZYPP_THROW(Exception ("At least one source already registered, cannot restore sources from persistent store.") );
+ ZYPP_THROW(Exception ( N_("At least one source already registered, cannot restore sources from persistent store.") ) );
+
+ FailedSourcesRestoreException report;
- bool error = false;
-
storage::PersistentStorage store;
store.init( root_r );
try {
id = addSource(it->url, it->product_dir, it->alias, it->cache_dir);
}
- catch ( const Exception & expt ){
+ catch ( Exception expt ){
ERR << "Unable to restore source from " << it->url << endl;
- error = true;
+ report.append( it->url + it->product_dir, expt );
continue;
}
src.setAutorefresh ( it->autorefresh );
}
- return !error;
+ if( !report.empty() )
+ {
+ ZYPP_THROW(report);
+ }
}
/******************************************************************
return *(it->second); // just to keep gcc happy
}
+ std::ostream & FailedSourcesRestoreException::dumpOn( std::ostream & str ) const
+ {
+ return str << _summary;
+ }
+
+ std::ostream & FailedSourcesRestoreException::dumpOnTranslated( std::ostream & str ) const
+ {
+ return str << Exception::asTranslatedString() << endl << _translatedSummary;
+ }
+
+ bool FailedSourcesRestoreException::empty () const
+ {
+ return _summary.empty();
+ }
+
+ void FailedSourcesRestoreException::append( std::string source, const Exception& expt)
+ {
+ _summary = _summary + "\n" + source + ": " + expt.asString();
+ _translatedSummary = _translatedSummary + "\n" + source + ": " + expt.asTranslatedString();
+
+ }
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
+#include "zypp/base/Gettext.h"
#include "zypp/Source.h"
#include "zypp/Url.h"
DEFINE_PTR_TYPE(SourceManager)
+ class FailedSourcesRestoreException : public Exception
+ {
+ public:
+ FailedSourcesRestoreException()
+ : Exception(N_("Unable to restore all sources."))
+ , _summary()
+ , _translatedSummary()
+ {}
+ virtual ~FailedSourcesRestoreException() throw() {};
+
+ void append( std::string source, const Exception& problem );
+ bool empty() const;
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ virtual std::ostream & dumpOnTranslated( std::ostream & str ) const;
+ private:
+ std::string _summary;
+ std::string _translatedSummary;
+ };
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : SourceManager