From 168b1909ae25f1fd653d1768647f5ed61dadc0bb Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Tue, 25 Mar 2014 12:19:42 +0000 Subject: [PATCH] Friendlier build error Hide the backtrace and show a comprehensible message. Closes #160. --- fig/cli/main.py | 5 ++++- fig/service.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fig/cli/main.py b/fig/cli/main.py index 4188d7708..d377e6836 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -9,7 +9,7 @@ from inspect import getdoc from .. import __version__ from ..project import NoSuchService, ConfigurationError -from ..service import CannotBeScaledError +from ..service import BuildError, CannotBeScaledError from .command import Command from .formatter import Formatter from .log_printer import LogPrinter @@ -51,6 +51,9 @@ def main(): except APIError as e: log.error(e.explanation) sys.exit(1) + except BuildError as e: + log.error("Service '%s' failed to build." % e.service.name) + sys.exit(1) # stolen from docopt master diff --git a/fig/service.py b/fig/service.py index 51ec004ba..f9a2b5c05 100644 --- a/fig/service.py +++ b/fig/service.py @@ -22,7 +22,8 @@ DOCKER_CONFIG_HINTS = { class BuildError(Exception): - pass + def __init__(self, service): + self.service = service class CannotBeScaledError(Exception): @@ -298,7 +299,7 @@ class Service(object): sys.stdout.write(line) if image_id is None: - raise BuildError() + raise BuildError(self) return image_id