Details
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T327527 Should our use cases throw exceptions instead of returning different response objects? | |||
Resolved | WMDE-leszek | T329947 ๐จ Use exceptions instead of response objects in previous use cases | |||
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T329954 ๐จ Modify GetItemLabels | |||
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T329956 ๐จ Modify GetItemStatement | |||
Resolved | Silvan_WMDE | T330050 ๐จ Modify RemoveItemStatement | |||
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T330051 ๐จ Modify ReplaceItemStatement | |||
Resolved | Silvan_WMDE | T330139 ๐จ Modify GetItemStatements | |||
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T330140 ๐จ Modify PatchItemStatement | |||
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T330166 ๐จ Modify AddItemStatement to throw use case exceptions | |||
Resolved | Muhammad_Yasser_Jazirahly_WMDE | T330167 ๐จ Modify GetItem to throw use case exceptions | |||
Resolved | Silvan_WMDE | T331978 ๐จ Create a base class for use case error and redirect exceptions |
Event Timeline
After using exceptions instead of response objects in the latest use case DescriptionsUseCase (T327881), and agreeing on using exceptions in the future, the remaining thing would be to modify older use cases.
Modifying older use cases plan:
- Use cases to be modified:
- Modify use cases to use exceptions instead of response objects.
- Modify validators by:
- Move the validation logic into the validator, in a new method assertValidRequest.
- Throw a UseCaseException inside the new method. (Would it always be this exception? Or is only for the invalid item ID?)
- Modify related route handler.
- Since there is now only one response for use cases (the SuccessResponse), we will rename it to just Response.
- Modify related tests.
Mini task breakdown to cleanup:
- In ResponseFactory, change newErrorResponse( ErrorResponse $useCaseResponse ) parameters to newErrorResponse( string $code, string $message, ?array $context )
- Remove the ErrorJsonPresenter and instead do the json_encode in the ResponseFactory::newErrorResponse method
- In the relevant middlewares, adjust the newErrorResponse arguments to match the parameter change
- Modify newErrorResponseFromException to get rid of the new ErrorResponse( ... ) and pass in the three arguments directly
- Move all public const error codes from ErrorResponse to UseCaseException
- Delete the ErrorResponse class
- Delete the ItemRedirectResponse class
- Discuss whether ItemRedirectException should be a subclass of UseCaseException or not
Change 896367 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):
[mediawiki/extensions/Wikibase@master] REST: Remove ErrorResponse from ResponseFactory
Change 896376 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):
[mediawiki/extensions/Wikibase@master] REST: Remove ErrorResponse
Change 896383 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):
[mediawiki/extensions/Wikibase@master] REST: Remove ErrorJsonPresenter.php
Change 896384 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):
[mediawiki/extensions/Wikibase@master] REST: Remove ItemRedirectResponse.php
Change 896367 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] REST: Remove ErrorResponse from ResponseFactory
Change 896376 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] REST: Remove ErrorResponse
Change 896383 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] REST: Remove ErrorJsonPresenter.php
Change 896384 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] REST: Remove ItemRedirectResponse.php