Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add errors to ProjectError message, duplicate code #8063

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Draft: add errors to ProjectError message
Signed-off-by: tobiasb <[email protected]>
Signed-off-by: sezanzeb <[email protected]>
  • Loading branch information
sezanzeb committed Jan 22, 2021
commit 1caac5a3730707e902818dda00b39ddf23013569
22 changes: 13 additions & 9 deletions compose/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ def update_labels(cls, value, labels):
raise ValueError("Invalid value for one_off: {}".format(repr(value)))


def raise_errors(errors):
"""
Raise multiple errors as ProjectError
"""
if len(errors):
combined_errors = '\n'.join([
e.decode('utf-8') if isinstance(e, bytes) else e for e in errors.values()
])
raise ProjectError(combined_errors)


class Project:
"""
A collection of services.
Expand Down Expand Up @@ -510,11 +521,7 @@ def build_service(service):
'Building',
limit=5,
)
if len(errors):
combined_errors = '\n'.join([
e.decode('utf-8') if isinstance(e, bytes) else e for e in errors.values()
])
raise ProjectError(combined_errors)
raise_errors(errors)

else:
for service in services:
Expand Down Expand Up @@ -707,10 +714,7 @@ def get_deps(service):
None,
get_deps,
)
if errors:
raise ProjectError(
'Encountered errors while bringing up the project.'
)
raise_errors(errors)

return [
container
Expand Down