summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-08-11 08:56:39 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2020-08-11 08:57:47 +0200
commit626b7ccc8cec120f789ef89c2d5d28b8b6d67a04 (patch)
tree449f3a3bf9e3cfeb74d72d9dd01b6aed49a8e0c6
parent23447e9b57a00482a5b26a7cb901f7bf4f28fa73 (diff)
acquire: Do not hide _errror messages in Fail()
If we have errors pending, always log them with our failure message to provide more context.
-rw-r--r--apt-pkg/acquire-method.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 9656caf14..486098c77 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -139,27 +139,30 @@ void pkgAcqMethod::SendMessage(std::string const &header, std::unordered_map<std
/* */
void pkgAcqMethod::Fail(bool Transient)
{
- string Err = "Undetermined Error";
- if (_error->empty() == false)
+
+ Fail("", Transient);
+}
+ /*}}}*/
+// AcqMethod::Fail - A fetch has failed /*{{{*/
+void pkgAcqMethod::Fail(string Err, bool Transient)
+{
+
+ if (not _error->empty())
{
- Err.clear();
- while (_error->empty() == false)
+ while (not _error->empty())
{
std::string msg;
if (_error->PopMessage(msg))
{
- if (Err.empty() == false)
+ if (not Err.empty())
Err.append("\n");
Err.append(msg);
}
}
}
- Fail(Err, Transient);
-}
- /*}}}*/
-// AcqMethod::Fail - A fetch has failed /*{{{*/
-void pkgAcqMethod::Fail(string Err,bool Transient)
-{
+ if (Err.empty())
+ Err = "Undetermined Error";
+
// Strip out junk from the error messages
std::transform(Err.begin(), Err.end(), Err.begin(), [](char const c) {
if (c == '\r' || c == '\n')