if (!confirm_licenses(non_interactive)) return ZYPPER_EXIT_OK;
cerr_v << "committing" << endl;
- ZYppCommitResult result = God->commit( ZYppCommitPolicy() );
- if (!result._errors.empty())
- retv = ZYPPER_EXIT_ERR_ZYPP;
- cerr_v << result << std::endl;
+
+ try {
+ ZYppCommitResult result = God->commit( ZYppCommitPolicy() );
+
+ if (!result._errors.empty())
+ retv = ZYPPER_EXIT_ERR_ZYPP;
+
+ cerr_v << result << std::endl;
+ }
+ catch ( const Exception & excpt_r ) {
+ ZYPP_CAUGHT( excpt_r );
+
+ // special handling for failed integrity exception
+ if (excpt_r.msg().find("fails integrity check") != string::npos) {
+ cerr << endl
+ << _("Package integrity check failed. This may be a problem"
+ " with installation source or media. Try one of the following:\n"
+ "\n"
+ "- just retry previous command\n"
+ "- refresh installation sources using 'zypper refresh'\n"
+ "- use another installation media (if e.g. damaged)\n"
+ "- use another installation source") << endl;
+ return ZYPPER_EXIT_ERR_ZYPP;
+ }
+ else
+ ZYPP_RETHROW( excpt_r );
+ }
}
}
virtual Action problem( zypp::Resolvable::constPtr resolvable_ptr, Error /*error*/, cbstring description )
{
+ // TODO read user's answer whether to retry or what. Consider non-interactive mode, too
std::cerr << resolvable_ptr << " " << description << std::endl;
std::cerr << "(aborting)" << std::endl;
return ABORT;
return ZYPPER_EXIT_ERR_BUG;
}
+/// tell to report a bug, and how
+// (multiline, with endls)
+ostream& report_a_bug (ostream& stm) {
+ return stm << _("Please report a bug about this.") << endl
+ // remember not to translate the URL
+ // unless you translate the actual page :)
+ << _("See http://en.opensuse.org/Zypper#Troubleshooting for instructions.") << endl;
+}
+
+/// process one command from the OS shell or the zypper shell
+// catch unexpected exceptions and tell the user to report a bug (#224216)
+int safe_one_command(const string& command, int argc, char **argv)
+{
+ int ret = ZYPPER_EXIT_ERR_BUG;
+ try {
+ ret = one_command (command, argc, argv);
+ }
+ catch (const Exception & ex) {
+ ZYPP_CAUGHT(ex);
+ cerr << _("Unexpected exception.") << endl;
+ cerr << ex.asUserString() << endl;
+ report_a_bug(cerr);
+ }
+ return ret;
+}
+
void command_shell ()
{
bool loop = true;
if (command == "exit")
loop = false;
else
- one_command (command, sh_argc, sh_argv);
+ safe_one_command (command, sh_argc, sh_argv);
}
}
if (command == "shell" || command == "sh")
command_shell ();
else
- ret = one_command (command, argc, argv);
+ ret = safe_one_command (command, argc, argv);
return ret;
}