From 626b7ccc8cec120f789ef89c2d5d28b8b6d67a04 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 11 Aug 2020 08:56:39 +0200 Subject: acquire: Do not hide _errror messages in Fail() If we have errors pending, always log them with our failure message to provide more context. --- apt-pkg/acquire-method.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'apt-pkg') 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_mapempty() == 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') -- cgit v1.2.3