Page MenuHomePhabricator

๐Ÿ“œ Catch `UseCaseErrorException` in route handler
Closed, ResolvedPublic

Description

  • Update the ErrorResponseToHttpStatus lookup class
    • Rename ErrorResponseToHttpStatus to UseCaseErrorToHttpStatus
    • Rename the lookup() method to lookupErrorResponse()
    • Add a lookupException( UseCaseErrorException $e ): int method
  • Create a new ExceptionJsonPresenter (similar to ErrorJsonPresenter)
  • Add a ResponseFactory::newErrorResponseFromException(Exception $e): Response method that uses the new ExceptionJsonPresenter class and UseCaseErrorToHttpStatus::lookupException() method
  • Add e2e tests

Event Timeline

Ollie.Shotton_WMDE renamed this task from ๐Ÿ“œ Catch `UseCaseErrorException` exceptions in route handler to ๐Ÿ“œ Catch `UseCaseErrorException` in route handler.Jan 31 2023, 5:20 PM

Change 886374 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Catch UseCaseErrorException in route handler

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

Creating an ExceptionJsonPresenter would mean having to inject it into the ResponseFactory for all routes which seemed a bit excessive for an experiment. Instead, I made the new ResponseFactory::newErrorResponseFromException() method just convert the exception to an ErrorResponse for now. This also means no changes to ErrorResponseToHttpStatus are needed either.

Change 886374 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Catch UseCaseErrorException in route handler

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