std::ifstream pfile( p.asString().c_str() );
if ( pfile.bad() ) {
- ZYPP_THROW(Exception("Error parsing media.1/media") );
+ ZYPP_THROW(SourceIOException("Can't read media.1/media") );
}
_media_vendor = str::getline( pfile, str::TRIM );
if ( pfile.fail() ) {
- ZYPP_THROW(Exception("Error parsing media.1/media") );
+ ZYPP_THROW(SourceIOException("Can't read media.1/media") );
}
_media_id = str::getline( pfile, str::TRIM );
if ( pfile.fail() ) {
- ZYPP_THROW(Exception("Error parsing media.1/media") );
+ ZYPP_THROW(SourceIOException("Can't read media.1/media") );
}
std::string media_count_str = str::getline( pfile, str::TRIM );
if ( pfile.fail() ) {
- ZYPP_THROW(Exception("Error parsing media.1/media") );
+ ZYPP_THROW(SourceIOException("Can't read media.1/media") );
}
_media_count = str::strtonum<unsigned>( media_count_str );
// init the cache structure
if (0 != assert_dir(local_dir + "DATA", 0755))
- ZYPP_THROW(Exception("Cannot create /DATA directory in download dir." + local_dir.asString()));
+ ZYPP_THROW(SourceIOException("Cannot create /DATA directory in download dir." + local_dir.asString()));
if (0 != assert_dir(local_dir + "MEDIA", 0755))
- ZYPP_THROW(Exception("Cannot create /MEDIA directory in download dir." + local_dir.asString()));
+ ZYPP_THROW(SourceIOException("Cannot create /MEDIA directory in download dir." + local_dir.asString()));
if (0 != assert_dir(local_dir + "PUBLICKEYS", 0755))
- ZYPP_THROW(Exception("Cannot create /PUBLICKEYS directory in download dir." + local_dir.asString()));
+ ZYPP_THROW(SourceIOException("Cannot create /PUBLICKEYS directory in download dir." + local_dir.asString()));
try {
media_src = provideDirTree("media.1");
}
catch(Exception &e) {
- ZYPP_THROW(Exception("Can't provide " + _path.asString() + "/media.1 from " + url().asString() ));
+ ZYPP_THROW(SourceIOException("Can't provide " + _path.asString() + "/media.1 from " + url().asString() ));
}
if ( filesystem::copy_dir(media_src, local_dir + "MEDIA") != 0 )
- ZYPP_THROW(Exception("Unable to copy media directory to " + (local_dir + "/MEDIA").asString()));
+ ZYPP_THROW(SourceIOException("Unable to copy media directory to " + (local_dir + "/MEDIA").asString()));
MIL << "cached media directory" << std::endl;
content_src = provideFile( _path + "content");
}
catch(Exception &e) {
- ZYPP_THROW(Exception("Can't provide " + _path.asString() + "/content from " + url().asString() ));
+ ZYPP_THROW(SourceIOException("Can't provide " + _path.asString() + "/content from " + url().asString() ));
}
if ( filesystem::copy(content_src, local_dir + "DATA/content") != 0)
- ZYPP_THROW(Exception("Unable to copy the content file to " + (local_dir + "DATA/content").asString()));
+ ZYPP_THROW(SourceIOException("Unable to copy the content file to " + (local_dir + "DATA/content").asString()));
// get the list of cache keys
std::list<std::string> files;
key_src = provideFile(_path + filename);
}
catch(Exception &e) {
- ZYPP_THROW(Exception("Can't provide " + (_path + filename).asString() + " from " + url().asString() ));
+ ZYPP_THROW(SourceIOException("Can't provide " + (_path + filename).asString() + " from " + url().asString() ));
}
MIL << "Trying to cache " << key_src << std::endl;
if ( filesystem::copy(key_src, local_dir + "PUBLICKEYS/" + filename) != 0 )
- ZYPP_THROW(Exception("Unable to copy key " + key_src.asString() + " to " + (local_dir + "PUBLICKEYS").asString()));
+ ZYPP_THROW(SourceIOException("Unable to copy key " + key_src.asString() + " to " + (local_dir + "PUBLICKEYS").asString()));
MIL << "cached " << filename << std::endl;
z->keyRing()->importKey(local_dir + "PUBLICKEYS/" + filename, false);
src_data = provideFile(_path + filename);
}
catch(Exception &e) {
- ZYPP_THROW(Exception("Can't provide " + filename + " from " + url().asString() + ". File was listed as available."));
+ ZYPP_THROW(SourceIOException("Can't provide " + filename + " from " + url().asString() + ". File was listed as available."));
}
if ( filesystem::copy( src_data, local_dir + "DATA/" + filename) != 0 )
- ZYPP_THROW(Exception("Unable to copy " + filename + " to " + (local_dir + "/DATA").asString()));
+ ZYPP_THROW(SourceIOException("Unable to copy " + filename + " to " + (local_dir + "/DATA").asString()));
if ( filename == "content.key" )
z->keyRing()->importKey(local_dir + "DATA/content.key", false);
// the source is not valid and the user did not want to continue
if (!valid)
- ZYPP_THROW (Exception( "Error. Source signature does not validate and user does not want to continue. "));
+ ZYPP_THROW (SourceUserRejectedException( "Error. Source signature does not validate and user does not want to continue. "));
// now we have the content file copied, we need to init data and descrdir from the product
readContentFile(local_dir + "/DATA/content");
// make sure a local descr dir exists
if ( assert_dir( local_dir + "/DATA/descr") != 0 )
- ZYPP_THROW (Exception( "Error. Can't create local descr directory. "));
+ ZYPP_THROW (SourceIOException( "Error. Can't create local descr directory. "));
// we can get the list of files in description dir in 2 ways
// from the checksum list, or ls'ing the dir via directory.yast
dirInfo( 1, descr_dir_file_list, mediaDescrDir());
}
catch(Exception &e) {
- ZYPP_THROW(Exception("Can't list description directory content from " + url().asString() ));
+ ZYPP_THROW(SourceIOException("Can't list description directory content from " + url().asString() ));
}
for( std::list<std::string>::const_iterator it = descr_dir_file_list.begin(); it != descr_dir_file_list.end(); ++it)
{
// refuse to use stupid paths as cache dir
if (cache_dir_r == Pathname("/") )
- ZYPP_THROW(Exception("I refuse to use / as cache dir"));
+ ZYPP_THROW(SourceIOException("I refuse to use / as cache dir"));
if (0 != assert_dir(cache_dir_r.dirname(), 0700))
- ZYPP_THROW(Exception("Cannot create cache directory" + cache_dir_r.asString()));
+ ZYPP_THROW(SourceIOException("Cannot create cache directory" + cache_dir_r.asString()));
filesystem::clean_dir(cache_dir_r);
filesystem::mkdir(cache_dir_r + "DATA");
need_to_refresh = downloadNeeded(dir_r);
}
catch(Exception &e) {
- ZYPP_THROW(Exception("Can't check if source has changed or not. Aborting refresh."));
+ ZYPP_THROW(SourceIOException("Can't check if source has changed or not. Aborting refresh."));
}
if ( need_to_refresh )
return;
}
- try {
- download_tmp_dir = downloadMetadata();
- }
- catch(Exception &e) {
- ZYPP_THROW(Exception("Downloading metadata failed (is a susetags source?) or user did not accept remote source. Aborting refresh."));
- }
-
+ download_tmp_dir = downloadMetadata();
copyLocalMetadata(download_tmp_dir, dir_r);
// download_tmp_dir go out of scope now but it is ok as we already copied the content.
void SuseTagsImpl::readContentFile(const Pathname &content_file)
{
SourceFactory factory;
- try {
+ try
+ {
DBG << "Going to parse content file " << content_file << endl;
ProductMetadataParser p;
MIL << "Read product: " << _product->summary() << endl;
_prodImpl = p.prodImpl;
- _autorefresh = p.volatile_content && media::MediaAccess::canBeVolatile( _url );
+ _autorefresh = p.volatile_content && media::MediaAccess::canBeVolatile( _url );
}
- catch (Exception & excpt_r) {
- ZYPP_THROW (Exception( "cannot parse content file."));
+ catch ( const Exception & e ) {
+ ZYPP_THROW (SourceMetadataException("Cannot parse content file: " + e.msg()));
}
}
progress.reset( new parser::ParserProgress( npp ) );
report->start( selfSourceRef(), "Parsing packages file" );
- PkgContent content( parsePackages( progress, source_r, this, p ) );
+
+ PkgContent content;
+
+ try {
+ content = parsePackages( progress, source_r, this, p );
+ }
+ catch ( const Exception &e )
+ {
+ report->finish( selfSourceRef(), "Parsing packages file", source::SourceReport::INVALID, e.msg() );
+ ZYPP_THROW(SourceMetadataException("Can't parse packages file: " + e.msg()));
+ }
report->finish( selfSourceRef(), "Parsing packages file", source::SourceReport::NO_ERROR, "" );
#warning Should use correct locale and locale fallback list
MIL << packages_lang_name << " found" << std::endl;
DBG << "Going to parse " << p << endl;
//verifyFile( p, packages_lang_name);
- parser::ParserProgress::Ptr progress;
- NullParseProgress npp(p);
- progress.reset( new parser::ParserProgress(npp) );
+
+ SourceEventHandler lang_progress_handler(report);
+ progress.reset( new parser::ParserProgress( lang_progress_handler ) );
+ report->start( selfSourceRef(), "Parsing translation: " + packages_lang_name );
parsePackagesLang( progress, this, p, lang, content );
trymore = false;
+ report->finish( selfSourceRef(), "Parsing translation: " + packages_lang_name, source::SourceReport::NO_ERROR, "" );
}
else
{
MIL << "Skipping translation candidate " << packages_lang_name << " (not present in media)" << endl;
}
}
- catch (Exception & excpt_r)
+ catch ( const Exception &e )
{
- ZYPP_CAUGHT(excpt_r);
+ report->finish( selfSourceRef(), "Parsing translation: " + packages_lang_name, source::SourceReport::INVALID, e.msg() );
+ ZYPP_CAUGHT(e);
}
lang = lang.fallback();
}