Author: jreidinger Date: Thu Mar 13 17:54:41 2008 New Revision: 9133 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9133&view=rev Log: get better message if something fail when trying run rpm (bnc #344584) Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc trunk/libzypp/zypp/target/rpm/RpmDb.h Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc?rev=9133&r1=9132&r2=9133&view=diff ============================================================================== --- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original) +++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Thu Mar 13 17:54:41 2008 @@ -887,7 +887,8 @@ if ( rpm_status != 0 ) { - ZYPP_THROW(RpmSubprocessException(string("rpm failed with message: ") + errmsg)); + ZYPP_THROW(RpmSubprocessException(string("RPM failed: ") + + (errmsg.empty() ? error_message: errmsg))); } else { @@ -1041,7 +1042,8 @@ if ( rpm_status != 0 ) { - ZYPP_THROW(RpmSubprocessException(string("Failed to import public key from file ") + pubkey_r.asString() + string(": rpm returned ") + str::numstring(rpm_status))); + ZYPP_THROW(RpmSubprocessException(string("Failed to import public key from file ") + + pubkey_r.asString() + ":" + error_message)); } else { @@ -1115,7 +1117,8 @@ if ( rpm_status != 0 ) { - ZYPP_THROW(RpmSubprocessException(string("Failed to remove public key ") + pubkey_r.asString() + string(": rpm returned ") + str::numstring(rpm_status))); + ZYPP_THROW(RpmSubprocessException(string("Failed to remove public key ") + + pubkey_r.asString() + ":" + error_message)); } else { @@ -1793,6 +1796,10 @@ return -1; exit_code = process->close(); + if (exit_code == 0) + error_message = ""; + else + error_message = process->execError(); process->kill(); delete process; process = 0; @@ -2044,7 +2051,8 @@ // %s = filename of rpm package progresslog(/*timestamp*/true) << str::form(_("%s install failed"), Pathname::basename(filename).c_str()) << endl; progresslog() << _("rpm output:") << endl << rpmmsg << endl; - ZYPP_THROW(RpmSubprocessException(string("RPM failed: ") + rpmmsg)); + ZYPP_THROW(RpmSubprocessException(string("RPM failed: ") + + (rpmmsg.empty() ? error_message : rpmmsg))); } else { @@ -2162,7 +2170,8 @@ // %s = name of rpm package progresslog(/*timestamp*/true) << str::form(_("%s remove failed"), name_r.c_str()) << endl; progresslog() << _("rpm output:") << endl << rpmmsg << endl; - ZYPP_THROW(RpmSubprocessException(string("RPM failed: ") + rpmmsg)); + ZYPP_THROW(RpmSubprocessException(string("RPM failed: ") + + (rpmmsg.empty() ? error_message: rpmmsg))); } else { Modified: trunk/libzypp/zypp/target/rpm/RpmDb.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.h?rev=9133&r1=9132&r2=9133&view=diff ============================================================================== --- trunk/libzypp/zypp/target/rpm/RpmDb.h (original) +++ trunk/libzypp/zypp/target/rpm/RpmDb.h Thu Mar 13 17:54:41 2008 @@ -406,6 +406,12 @@ * The exit code of the rpm process, or -1 if not yet known. */ int exit_code; + + /** + * Error message from running rpm as external program. + * Use only if something fail. + */ + std::string error_message; /** /var/adm/backup */ Pathname _backuppath; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org