( )⚙ D6840 hgweb: add a `message` attribute to `hgweb.common.ErrorResponse`

This is an archive of the discontinued Mercurial Phabricator instance.

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

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

Details

Summary

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.

[1] https://www.mercurial-scm.org/repo/hg-committed/file/6ccf539aec71/mercurial/hgweb/hgwebdir_mod.py#l459

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

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/hgwebdir_mod.py", line 358, in run_wsgi
    for r in self._runwsgi(req, res):
  File "/var/hg/venv_hgweb/lib64/python3.6/site-packages/mercurial/hgweb/hgwebdir_mod.py", 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