Page MenuHomePhabricator

hgweb: add a `message` attribute to `hgweb.common.ErrorResponse`

Authored by sheehan on Sep 10 2019, 4:10 PM.



This fixes a Python 3 bug where hgweb assumes an Exception
subclass will have a .message attribute after running
Exception.__init__.[1] The Python 3 way to get this info would
be e.args[0], but adding a new named attribute is more
ergonomic in my view.


Diff Detail

rHG Mercurial
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

sheehan created this revision.Sep 10 2019, 4:10 PM

The error I mentioned looks like this:

Traceback (most recent call last):
  File "/var/hg/venv_hgweb/lib64/python3.6/site-packages/mercurial/hgweb/", line 358, in run_wsgi
    for r in self._runwsgi(req, res):
  File "/var/hg/venv_hgweb/lib64/python3.6/site-packages/mercurial/hgweb/", line 463, in _runwsgi
    res.setbodygen(tmpl.generate('error', {'error': e.message or ''}))
AttributeError: 'ErrorResponse' object has no attribute 'message'
pulkit accepted this revision.Sep 11 2019, 2:26 AM
This revision is now accepted and ready to land.Sep 11 2019, 2:26 AM