Browse Source

Improve Rx exception messages

pull/190/head
Oliverpool 9 years ago
parent
commit
957cb756c8
  1. 10
      patacrep/build.py
  2. 2
      patacrep/errors.py
  3. 3
      patacrep/templates.py

10
patacrep/build.py

@ -48,7 +48,7 @@ class Songbook:
try:
utils.validate_yaml_schema(raw_songbook, schema)
except errors.SchemaError as exception:
exception.message = "The songbook file '{}' is not valid".format(basename)
exception.message = "The songbook file '{}' is not valid\n".format(basename)
raise exception
self._raw_config = raw_songbook
@ -89,7 +89,13 @@ class Songbook:
self._config['book']['lang'],
self._config['book']['encoding'],
)
self._config['_template'] = renderer.get_all_variables(self._config.get('template', {}))
try:
self._config['_template'] = renderer.get_all_variables(self._config.get('template', {}))
except errors.SchemaError as exception:
exception.message = "The songbook file '{}' is not valid\n{}".format(
self.basename, exception.message)
raise exception
self._config['_compiled_authwords'] = authors.compile_authwords(
copy.deepcopy(self._config['authors'])

2
patacrep/errors.py

@ -17,7 +17,7 @@ class SchemaError(SongbookError):
def __str__(self):
if self.rx_exception:
return self.message + "\n" + str(self.rx_exception)
return self.message + str(self.rx_exception)
else:
return self.message

3
patacrep/templates.py

@ -173,8 +173,7 @@ class TexBookRenderer(Renderer):
try:
variables[templatename] = self._get_variables(param, template_config)
except errors.SchemaError as exception:
exception.message = "The songbook file is not valid\n"
exception.message += "'template' > '{}' >".format(templatename)
exception.message += "'template' > '{}' > ".format(templatename)
raise exception
return variables

Loading…
Cancel
Save