- fixed error message of zypper ar -r (#306667)
authorJan Kupec <jkupec@suse.cz>
Fri, 31 Aug 2007 12:34:19 +0000 (12:34 +0000)
committerJan Kupec <jkupec@suse.cz>
Fri, 31 Aug 2007 12:34:19 +0000 (12:34 +0000)
src/zypper-misc.cc
src/zypper-sources.cc

index 7df1ab7..ba971a2 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <zypp/RepoManager.h>
 #include <zypp/RepoInfo.h>
-#include <zypp/repo/RepoException.h>
 
 #include <zypp/CapFactory.h>
 
index 605656a..28e5f8a 100644 (file)
@@ -784,8 +784,37 @@ int add_repo_from_file(const std::string & repo_file_url,
   //! \todo handle local .repo files, validate the URL
   Url url(repo_file_url);
   RepoManager manager;
-  list<RepoInfo> repos = readRepoFile(url);
+  list<RepoInfo> repos;
+
+  // read the repo file
+  try { repos = readRepoFile(url); }
+  catch (const media::MediaException & e)
+  {
+    ZYPP_CAUGHT(e);
+    report_problem(e,
+      _("Problem accessing the file at the specified URL") + string(":"),
+      _("Please check if the URL is valid and accessible."));
+    return ZYPPER_EXIT_ERR_ZYPP;
+  }
+  catch (const parser::ParseException & e)
+  {
+    ZYPP_CAUGHT(e);
+    report_problem(e,
+      _("Problem parsing the file at the specified URL") + string(":"),
+      // TranslatorExplanation don't translate the URL if the URL itself is not translated.
+      // Also don't translate the '.repo' string.
+      _("Is it a .repo file? See http://en.opensuse.org/Standards/RepoInfo for details."));
+    return ZYPPER_EXIT_ERR_ZYPP;
+  }
+  catch (const Exception & e)
+  {
+    ZYPP_CAUGHT(e);
+    report_problem(e,
+      _("Problem encountered while trying to read the file at the specified URL") + string(":"));
+    return ZYPPER_EXIT_ERR_ZYPP;
+  }
 
+  // add repos
   for (list<RepoInfo>::const_iterator it = repos.begin();
        it !=  repos.end(); ++it)
   {