Description
ZErrorException wraps a ZError. ZError builds the error message by making all the necessary fetches to the DB and getting the labels of the persisted objects.
Often internal errors should be handled and passed through lightly, so that a database-related error doesn't necessarily generate N other database operations.
Possible solutions:
- Have different WikiLambda exceptions that are used internally.
- Only build ZError and ZErrorExceptions when preparing a response to the user.
- Refactor ZError so that it instantiates a given ZError without extra fetches:
- ZError->isValid() fetches for the ZErrorType in the DB to validate that it is a Z50
- ZError->getMessage() and ZError->getHtmlMessage() fetch ZErrorType in the DB to get the labels and build the message
- We could create the ZError message on demand, when generating the response, but not on instantiation of the ZError
Desired behavior/Acceptance criteria
- catching and propagating internal exceptions doesn't generate fetches
- catching and propagating internal errors propagates the necessary info to build detailed responses
- we have more control on creating a ZErrorException whenever we want to build a response
Completion checklist
- Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Front-end_Task/Bug_Completion_Checklist