mirror of https://github.com/docker/compose.git
Catchable error for parse failures in split_buffer
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
1c07d6453f
commit
bd7db570bd
|
@ -23,6 +23,7 @@ from ..config.environment import Environment
|
|||
from ..config.serialize import serialize_config
|
||||
from ..const import DEFAULT_TIMEOUT
|
||||
from ..const import IS_WINDOWS_PLATFORM
|
||||
from ..errors import StreamParseError
|
||||
from ..progress_stream import StreamOutputError
|
||||
from ..project import NoSuchService
|
||||
from ..project import OneOffFilter
|
||||
|
@ -75,7 +76,7 @@ def main():
|
|||
except NeedsBuildError as e:
|
||||
log.error("Service '%s' needs to be built, but --no-build was passed." % e.service.name)
|
||||
sys.exit(1)
|
||||
except errors.ConnectionError:
|
||||
except (errors.ConnectionError, StreamParseError):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
|
@ -5,3 +5,8 @@ from __future__ import unicode_literals
|
|||
class OperationFailedError(Exception):
|
||||
def __init__(self, reason):
|
||||
self.msg = reason
|
||||
|
||||
|
||||
class StreamParseError(RuntimeError):
|
||||
def __init__(self, reason):
|
||||
self.msg = reason
|
||||
|
|
|
@ -9,6 +9,8 @@ import logging
|
|||
|
||||
import six
|
||||
|
||||
from .errors import StreamParseError
|
||||
|
||||
|
||||
json_decoder = json.JSONDecoder()
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -64,12 +66,12 @@ def split_buffer(stream, splitter=None, decoder=lambda a: a):
|
|||
if buffered:
|
||||
try:
|
||||
yield decoder(buffered)
|
||||
except ValueError:
|
||||
except Exception as e:
|
||||
log.error(
|
||||
'Compose tried parsing the following chunk as a JSON object, '
|
||||
'but failed:\n%s' % repr(buffered)
|
||||
'Compose tried decoding the following data chunk, but failed:'
|
||||
'\n%s' % repr(buffered)
|
||||
)
|
||||
raise
|
||||
raise StreamParseError(e)
|
||||
|
||||
|
||||
def json_splitter(buffer):
|
||||
|
|
Loading…
Reference in New Issue