Author: jkupec
Date: Thu Aug 9 14:40:44 2007
New Revision: 6549
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6549&view=rev
Log:
- addrepo error reporting improved
Modified:
trunk/zypper/src/zypper-callbacks.cc
trunk/zypper/src/zypper-callbacks.h
trunk/zypper/src/zypper-sources.cc
Modified: trunk/zypper/src/zypper-callbacks.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.cc?rev=6549&r1=6548&r2=6549&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.cc (original)
+++ trunk/zypper/src/zypper-callbacks.cc Thu Aug 9 14:40:44 2007
@@ -188,6 +188,39 @@
return ss.str ();
}
+// ----------------------------------------------------------------------------
+
+void report_zypp_exception(const zypp::Exception & e)
+{
+ if (e.historySize())
+ {
+ if (gSettings.verbosity > 2)
+ // print the whole history
+ cerr << e.historyAsString();
+ else
+ // print the root cause
+ cerr << *e.historyEnd();
+ }
+ else
+ cerr << e.asUserString();
+ cerr << endl;
+}
+
+void report_problem(const zypp::Exception & e,
+ const string & problem_desc,
+ const string & hint)
+{
+ // problem
+ cerr << problem_desc << endl;
+
+ // cause
+ report_zypp_exception(e);
+
+ // hint
+ if (!hint.empty())
+ cerr << hint << endl;
+}
+
// Local Variables:
// c-basic-offset: 2
// End:
Modified: trunk/zypper/src/zypper-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.h?rev=6549&r1=6548&r2=6549&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.h (original)
+++ trunk/zypper/src/zypper-callbacks.h Thu Aug 9 14:40:44 2007
@@ -14,6 +14,7 @@
#include <string>
#include
+#include
#include "zypper.h"
@@ -64,5 +65,29 @@
*/
bool read_bool_answer(const string & question, bool default_answer);
+/**
+ * Returns string representation of a resolvable.
+ */
std::string to_string (zypp::Resolvable::constPtr resolvable);
+
+/**
+ * Prints exception message. If there is exception history available for the
+ * exception, this method prints the root cause or the whole history (if
+ * verbosity level is >2). Otherwise it just prist the e.asUserString() of the
+ * exception passed.
+ */
+void report_zypp_exception(const zypp::Exception & e);
+
+/**
+ * Prints the problem description caused by an exception, its cause and,
+ * optionaly, a hint for the user.
+ *
+ * \param e Exception which caused the problem.
+ * \param Problem description for the user.
+ * \param Hint for the user how to cope with the problem.
+ */
+void report_problem(const zypp::Exception & e,
+ const string & problem_desc,
+ const string & hint = "");
+
#endif
Modified: trunk/zypper/src/zypper-sources.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.cc?rev=6549&r1=6548&r2=6549&view=diff
==============================================================================
--- trunk/zypper/src/zypper-sources.cc (original)
+++ trunk/zypper/src/zypper-sources.cc Thu Aug 9 14:40:44 2007
@@ -1,8 +1,3 @@
-
-#include "zypper.h"
-#include "zypper-sources.h"
-#include "zypper-tabulator.h"
-
#include <iostream>
#include <fstream>
#include
@@ -18,6 +13,11 @@
#include
#include
+#include "zypper.h"
+#include "zypper-tabulator.h"
+#include "zypper-callbacks.h"
+#include "zypper-sources.h"
+
using namespace std;
using namespace zypp;
using namespace zypp::repo;
@@ -432,42 +432,42 @@
{
manager.addRepository(repo);
}
- catch (const MediaException & e)
- {
- cerr << _("Problem transfering repository data from specified URL.") << endl;
- ERR << "Problem transfering repository data from specified URL." << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
- }
- catch (const ParseException & e)
- {
- cerr << _("Problem parsing repository data.") << endl;
- ERR << "Problem parsing repository data." << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
- }
catch (const RepoAlreadyExistsException & e)
{
- cerr << format("Repository named '%s' already exists.") % repo.alias() << endl;
+ ZYPP_CAUGHT(e);
+ cerr << format(_("Repository named '%s' already exists. Please, use another alias."))
+ % repo.alias() << endl;
ERR << "Repository named '%s' already exists." << endl;
return ZYPPER_EXIT_ERR_ZYPP;
}
catch (const RepoUnknownTypeException & e)
{
- cerr << format(_("Can't find a valid repository at given location")) << endl;
- ERR << "Problem parsing repository data." << endl;
+ ZYPP_CAUGHT(e);
+ cerr << _("Can't find a valid repository at given location:") << endl;
+ cerr << _("Could not determine the type of the repository."
+ " Please, check if the defined URLs (see below) point to a valid repository:");
+ for(RepoInfo::urls_const_iterator uit = repo.baseUrlsBegin();
+ uit != repo.baseUrlsEnd(); ++uit)
+ cerr << (*uit) << endl;
return ZYPPER_EXIT_ERR_ZYPP;
}
catch (const RepoException & e)
{
- cerr << e.msg() << endl;
+ ZYPP_CAUGHT(e);
+ report_problem(e,
+ _("Problem transfering repository data from specified URL:"),
+ _("Please, check whether the specified URL is accessible."));
+ ERR << "Problem transfering repository data from specified URL" << endl;
return ZYPPER_EXIT_ERR_ZYPP;
}
catch (const Exception & e)
{
ZYPP_CAUGHT(e);
- cerr << e.asUserString() << endl;
+ report_problem(e, _("Unknown problem when adding repository:"));
return ZYPPER_EXIT_ERR_BUG;
}
+ //! \todo different output for -r and for zypper.
cout_n << format(_("Repository '%s' successfully added:")) % repo.alias() << endl;
cout_n << ( repo.enabled() ? "[x]" : "[ ]" );
cout_n << ( repo.autorefresh() ? "* " : " " );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org