Skip to content

Commit

Permalink
Catching one more error
Browse files Browse the repository at this point in the history
  • Loading branch information
bthornto committed Nov 30, 2017
1 parent 55de7da commit b882900
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apk add gcc libffi-dev musl-dev openssl-dev sshpass make
# RUN apk add py-crypto python-dev

# Install td4a
RUN pip install td4a==1.3
RUN pip install td4a==1.5

# Clear out extras
RUN rm -rf /var/cache/apk/*
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(name='td4a',
version='1.3',
version='1.5',
description='A browser based jinja template renderer',
url='http://github.com/cidrblock/td4a',
author='Bradley A. Thornton',
Expand Down
13 changes: 12 additions & 1 deletion td4a/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from jinja2 import meta, Environment, TemplateSyntaxError, StrictUndefined
from ruamel.yaml import YAML
from ruamel.yaml.compat import StringIO
from ruamel.yaml.constructor import DuplicateKeyError
from ruamel.yaml.constructor import DuplicateKeyError, ConstructorError
from ruamel.yaml.scanner import ScannerError
from ruamel.yaml.parser import ParserError
from twisted.internet import reactor
Expand Down Expand Up @@ -139,6 +139,17 @@ def load_data(str_data):
yaml = MYYAML()
data = yaml.load(str_data)
return None, data
except ConstructorError, error:
mark = error.problem_mark
message = next(x for x in str(error).splitlines() if x.startswith('found'))
return {"Error":
{
"in": "data",
"title": "Issue found loading data. Quotes needed?. %s" % repr(error),
"line_number": mark.line+1,
"details": "%s" % message
}
}, None
except ParserError, error:
mark = error.problem_mark
message = next(x for x in str(error).splitlines() if x.startswith('expected'))
Expand Down

0 comments on commit b882900

Please sign in to comment.