Wikibase
MediaWiki Wikibase extension
|
Accepted
Currently, our UseCases can return three different types of response objects:
GetItemLabelsSuccessResponse
)ItemRedirectResponse
ErrorResponse
(e.g. GetItemLabelsErrorResponse
)While discussing Chapter 9: Validation of Advanced Web Application Architecture
, we decided it would be useful to try out only returning a success response object from a UseCase and throwing an exception in the other situations.
We perceive that the benefits of throwing exceptions would be:
execute()
method would only need a single return type instead of union types.instanceof
checks in if
/elseif
/else
(or switch
) statements.execute()
method.Keep current ErrorResponse
and ItemRedirectResponse
, without throwing exceptions.
By trying to use exceptions instead of response objects in either an already implemented UseCase with a single RouteHandler
like GetItemLabels
, or when creating a new UseCase e.g. GetItemDescriptions
or GetItemAliases
.
We decided to go with action 2: switch to throwing use case exceptions instead of returning different kinds of response objects.
GetItemLabelsSuccessResponse
-> GetItemLabelsResponse
).