# HG changeset patch # User David Barts # Date 1558061882 25200 # Node ID 448fc3d534f88768b4f8f4451d10f35e30d7f2a7 # Parent 560c8fb55e4a1d867cea1c853fa55d898ad50bde Improve error reportage. diff -r 560c8fb55e4a -r 448fc3d534f8 tincan.py --- a/tincan.py Thu May 16 18:42:22 2019 -0700 +++ b/tincan.py Thu May 16 19:58:02 2019 -0700 @@ -397,8 +397,13 @@ if self._header.template is not None: if not self._header.template.endswith(_TEXTEN): raise TinCanError("{0}: #template files must end in {1}".format(self._urlpath, _TEXTEN)) - tpath = os.path.normpath(os.path.join(self._fsroot, *self._splitpath(self._header.template))) - tfile = TemplateFile(tpath) + try: + tpath = os.path.normpath(os.path.join(self._fsroot, *self._splitpath(self._header.template))) + tfile = TemplateFile(tpath) + except OSError as e: + raise TinCanError("{0}: invalid #template: {1!s}".format(self._urlpath, e)) from e + except IndexError as e: + raise TinCanError("{0}: invalid #template".format(self._urlpath)) from e self._body = self._tclass(source=tfile.body) else: self._body = self._tclass(source=self._template.body) @@ -470,7 +475,7 @@ mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) except Exception as e: - raise TinCanError("{0}: error importing".format(pycpath)) from e + raise TinCanError("{0}: error importing: {1!s}".format(pycpath, e)) from e # Locate a suitable class self._class = None for i in dir(mod):