diff --git a/salt/serializers/yaml.py b/salt/serializers/yaml.py index debbd39caf..7636d7dfa1 100644 --- a/salt/serializers/yaml.py +++ b/salt/serializers/yaml.py @@ -11,6 +11,7 @@ from __future__ import absolute_import import datetime +import logging import yaml from yaml.constructor import ConstructorError @@ -22,6 +23,8 @@ from salt.utils.odict import OrderedDict __all__ = ['deserialize', 'serialize', 'available'] +log = logging.getLogger(__name__) + available = True # prefer C bindings over python when available @@ -46,14 +49,17 @@ def deserialize(stream_or_string, **options): try: return yaml.load(stream_or_string, **options) except ScannerError as error: + log.exception('Error encountered while deserializing') err_type = ERROR_MAP.get(error.problem, 'Unknown yaml render error') line_num = error.problem_mark.line + 1 raise DeserializationError(err_type, line_num, error.problem_mark.buffer) except ConstructorError as error: + log.exception('Error encountered while deserializing') raise DeserializationError(error) except Exception as error: + log.exception('Error encountered while deserializing') raise DeserializationError(error) @@ -74,6 +80,7 @@ def serialize(obj, **options): return response[:-1] return response except Exception as error: + log.exception('Error encountered while serializing') raise SerializationError(error) diff --git a/salt/serializers/yamlex.py b/salt/serializers/yamlex.py index 0a648bb7e3..ac8a21d595 100644 --- a/salt/serializers/yamlex.py +++ b/salt/serializers/yamlex.py @@ -150,14 +150,17 @@ def deserialize(stream_or_string, **options): try: return yaml.load(stream_or_string, **options) except ScannerError as error: + log.exception('Error encountered while deserializing') err_type = ERROR_MAP.get(error.problem, 'Unknown yaml render error') line_num = error.problem_mark.line + 1 raise DeserializationError(err_type, line_num, error.problem_mark.buffer) except ConstructorError as error: + log.exception('Error encountered while deserializing') raise DeserializationError(error) except Exception as error: + log.exception('Error encountered while deserializing') raise DeserializationError(error) @@ -178,6 +181,7 @@ def serialize(obj, **options): return response[:-1] return response except Exception as error: + log.exception('Error encountered while serializing') raise SerializationError(error)