Page MenuHomePhabricator

PHP REST router should gracefully handle exceptions.
Closed, ResolvedPublic

Description

This came up in the context of T276385:

ret.php has no handling for exceptions other than HTTPException. It should have at least basic handling for all exceptions, based on Exception::getMessage(). The handling should happen in the Router class.

The response should be either JSON or HTML (to be decided).

We could also consider introducing an interface that is shared by LocalizedHTTPException, ErrorPageError, and ApiUseageException, to provide additional information.

Note that uncaught exceptions still need to be logged appropriately, in the same way we would do that for requests coming in from api.php or index.php.

Event Timeline

Change 702917 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] REST: gracefully handle all exceptions.

https://gerrit.wikimedia.org/r/702917

Change 702917 merged by jenkins-bot:

[mediawiki/core@master] REST: gracefully handle all exceptions.

https://gerrit.wikimedia.org/r/702917

matmarex subscribed.

Looks like this was resolved by the patch in 2021.