Mercurial > cgi-bin > hgweb.cgi > tincan
changeset 69:c168aad7a731 draft
Fix template error reportage.
author | David Barts <n5jrn@me.com> |
---|---|
date | Mon, 15 Jul 2019 08:13:51 -0700 |
parents | 61667621e19d |
children | a78c74c73d98 |
files | tincan.py |
diffstat | 1 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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))