# HG changeset patch # User David Barts # Date 1563203631 25200 # Node ID c168aad7a7316d69508e0c8ff4dad939fd19798b # Parent 61667621e19d208e38a22e784f00af244968a3d7 Fix template error reportage. diff -r 61667621e19d -r c168aad7a731 tincan.py --- a/tincan.py Mon Jul 15 00:15:25 2019 -0700 +++ b/tincan.py Mon Jul 15 08:13:51 2019 -0700 @@ -568,12 +568,8 @@ while True: try: self._template = TemplateFile(self._fspath) - except IOError as e: - if oheader is not None: - note = "{0}: invalid #forward: ".format(self._origin) - else: - note = "" - raise TinCanError("{0}{1!s}".format(note, e)) from e + except (OSError, UnicodeError) as e: + raise TinCanError("{0}: {1!s}".format(self._fspath, e)) from e try: self._header = TemplateHeader(self._template.header) except TemplateHeaderError as e: @@ -605,12 +601,15 @@ if self._header.template is not None: if not _casef(self._header.template).endswith(_TEXTEN): raise TinCanError("{0}: #template files must end in {1}".format(self._urlpath, _TEXTEN)) + tpath = None try: rtpath = self._splitpath(self._header.template) tpath = os.path.normpath(os.path.join(self._fsroot, *rtpath)) tfile = TemplateFile(tpath) except OSError as e: raise TinCanError("{0}: invalid #template: {1!s}".format(self._urlpath, e)) from e + except UnicodeError as e: + raise TinCanError("{0}: {1!s}".format(tpath, e)) from e except IndexError as e: raise TinCanError("{0}: invalid #template".format(self._urlpath)) from e self._body = self._mktemplate(tfile.body, self.urljoin(*rtpath))