From 27c69dd0b36e3da7b6061e597d755f5a60a0d31b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 10 May 2011 13:00:56 +0200 Subject: send the first line of the error message to the error list and fail a bit more nicely and in order --- apt-pkg/edsp.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 0e229e1c0..218ce9f24 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -274,10 +274,18 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres } continue; } else if (section.Exists("Error") == true) { + std::string msg = SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n"); + if (msg.empty() == true) { + msg = _("External solver failed without a proper error message"); + _error->Error(msg.c_str()); + } else + _error->Error("External solver failed with: %s", msg.substr(0,msg.find('\n')).c_str()); + if (Progress != NULL) + Progress->Done(); std::cerr << "The solver encountered an error of type: " << section.FindS("Error") << std::endl; std::cerr << "The following information might help you to understand what is wrong:" << std::endl; - std::cerr << SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n") << std::endl << std::endl; - break; + std::cerr << msg << std::endl << std::endl; + return false; } else if (section.Exists("Autoremove") == true) type = "Autoremove"; else @@ -549,7 +557,7 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache, if (Progress != NULL) Progress->OverallProgress(25, 100, 75, _("Execute external solver")); if (EDSP::ReadResponse(solver_out, Cache, Progress) == false) - return _error->Error("Reading solver response failed"); + return false; return true; } -- cgit v1.2.3