- 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
Description
Description
Details
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
REST: Catch UseCaseErrorException in route handler | mediawiki/extensions/Wikibase | master | +33 -3 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T327527 Should our use cases throw exceptions instead of returning different response objects? | |||
Resolved | Ifrahkhanyaree_WMDE | T344228 Functionality for REST API v1 | |||
Resolved | WMDE-leszek | T327881 ๐ Provide data of all item's descriptions | |||
Resolved | Ollie.Shotton_WMDE | T328467 ๐ Catch `UseCaseErrorException` in route handler |
Event Timeline
Comment Actions
Change 886374 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):
[mediawiki/extensions/Wikibase@master] REST: Catch UseCaseErrorException in route handler
Comment Actions
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.
Comment Actions
Change 886374 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] REST: Catch UseCaseErrorException in route handler