commit: a189abfaca3603bf1c298e92eb755c117e0e7fa2 Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Sun Oct 16 19:04:32 2022 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Sun Oct 16 19:10:33 2022 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=a189abfa
operations.fetch: better error messages when fetching fails Improve the error messages when we have fetch failures. Till now we were always outputting the first version of the package in error, and weren't listing which distfiles failed. Now we output all failures separately, use a special FetchError exception class, and output unversioned atom in final error message. Resolves: https://github.com/pkgcore/pkgdev/issues/86 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcore/operations/format.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pkgcore/operations/format.py b/src/pkgcore/operations/format.py index cdb16fdc0..d66eaf192 100644 --- a/src/pkgcore/operations/format.py +++ b/src/pkgcore/operations/format.py @@ -4,7 +4,7 @@ build operation __all__ = ( 'build_base', 'install', 'uninstall', 'replace', 'fetch_base', - 'empty_build_op', 'FailedDirectory', 'GenericBuildError', + 'empty_build_op', 'FailedDirectory', 'GenericBuildError', 'FetchError', ) import os @@ -133,8 +133,10 @@ class operations(_operations_mod.base): build_ops = self.domain.build_pkg(pkgwrap, observer, failed=True) build_ops.nofetch() build_ops.cleanup(force=True) - observer.error('failed fetching files: %s::%s', self.pkg.cpvstr, self.pkg.repo.repo_id) - raise GenericBuildError('failed fetching required distfiles') + for fetchable in failures: + observer.error('failed fetching %s', fetchable.uri) + observer.error('failed fetching files for package %s::%s', self.pkg.unversioned_atom, self.pkg.repo.repo_id) + raise FetchError(failures) self.verified_files = verified return True @@ -335,3 +337,9 @@ class GenericBuildError(BuildError): def __init__(self, err): super().__init__(f"failed build operation: {err}") self.err = str(err) + + +class FetchError(BuildError): + def __init__(self, failures): + super().__init__("failed fetching required distfiles") + self.err = str(failures)
