diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-03-12 18:05:55 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-04-25 15:35:52 +0200 |
commit | 6563390031a88ffd85308ac3c26ea9d10bc6bc99 (patch) | |
tree | 57c8ac0500154c4947c1089a81b03f7f6fe1ae7d /apt-private/acqprogress.cc | |
parent | 3f7604340855760289d7ed7e2dca70f99a9f4986 (diff) |
format multiline errors properly in acquire progress
Together with the GlobalError change this allows us to add errors
spanning multiple lines, just that we control GlobalError while the
acquire progress is dealt with potentially by individual clients which
might or might not need to be adapted.
This isn't critical through as it either just works as expected anyhow
or is a minor styling thing (after all, all this commit does it add two
spaces to indent the lines a bit…).
Diffstat (limited to 'apt-private/acqprogress.cc')
-rw-r--r-- | apt-private/acqprogress.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index a33d51c71..c182fa02d 100644 --- a/apt-private/acqprogress.cc +++ b/apt-private/acqprogress.cc @@ -121,24 +121,40 @@ void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm) AssignItemID(Itm); clearLastLine(); + bool ShowErrorText = true; if (Itm.Owner->Status == pkgAcquire::Item::StatDone || Itm.Owner->Status == pkgAcquire::Item::StatIdle) { // TRANSLATOR: Very short word to be displayed for files in 'apt-get update' // which failed to download, but the error is ignored (compare "Err:") ioprintf(out, _("Ign:%lu %s"), Itm.Owner->ID, Itm.Description.c_str()); - if (Itm.Owner->ErrorText.empty() == false && - _config->FindB("Acquire::Progress::Ignore::ShowErrorText", false) == true) - out << std::endl << " " << Itm.Owner->ErrorText; - out << std::endl; + if (Itm.Owner->ErrorText.empty() || + _config->FindB("Acquire::Progress::Ignore::ShowErrorText", false) == false) + ShowErrorText = false; } else { // TRANSLATOR: Very short word to be displayed for files in 'apt-get update' // which failed to download and the error is critical (compare "Ign:") ioprintf(out, _("Err:%lu %s"), Itm.Owner->ID, Itm.Description.c_str()); - out << std::endl << " " << Itm.Owner->ErrorText << std::endl; } + if (ShowErrorText) + { + std::string::size_type line_start = 0; + std::string::size_type line_end; + while ((line_end = Itm.Owner->ErrorText.find_first_of("\n\r", line_start)) != std::string::npos) { + out << std::endl << " " << Itm.Owner->ErrorText.substr(line_start, line_end - line_start); + line_start = Itm.Owner->ErrorText.find_first_not_of("\n\r", line_end + 1); + if (line_start == std::string::npos) + break; + } + if (line_start == 0) + out << std::endl << " " << Itm.Owner->ErrorText; + else if (line_start != std::string::npos) + out << std::endl << " " << Itm.Owner->ErrorText.substr(line_start); + } + out << std::endl; + Update = true; } /*}}}*/ |