aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Rest/LocalizedHttpException.php
Commit message (Collapse)AuthorAgeFilesLines
* Rest: Make LocalizedHttpException emit a stable error codeGergő Tisza2023-02-011-4/+17
| | | | | | | | | | | | | | | | | | | | When a LocalizedHttpException is created with a DataMessageValue, show the error code to clients (named 'errorKey' to avoid confusion with the HTTP error code) so it's easier for them to gather debugging data, have specific handling for certain errors etc. For plain MessageValue, use the message key for lack of a better option. This is roughly identical to how error handling in the Action API works. Also tighten up HttpException's $errorData / getData() parameter to be strictly an array - it doesn't make any sense to pass null for data. Technically this is a B/C break but passing null is an exceedingly unlikely usage pattern, and there is no instance of it in codesearch. Change-Id: I3626febed6a0402361a461d96942a863fa230ed0
* Replace "@stable for calling" by "@stable to call"daniel2020-07-131-1/+1
| | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
* Correctly annotate types for Rest exceptions.Petr Pchelko2020-07-091-1/+1
| | | | Change-Id: I7ac5d10dbd49777dba2605b27777376253d73938
* Mark exceptions as @newabledaniel2020-07-081-0/+10
| | | | | | | | Exceptions classes are nearly always value objects, and should in most cases by newable. Bug: T247862 Change-Id: I4faa8ec6ea8bc44086cfc8075b32d10eea61e9df
* ParamValidator: Use MessageValue!Brad Jorsch2019-11-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Trying to get away with returning a single code and parameter-list that was supposed to represent both human-readable and machine-readable data was a mistake. This patch converts it to use DataMessageValue, which represents the two separately and also provides guidance for supplying translations of all the error codes. This also eliminates the "describeSettings()" method that was trying to serve multiple use cases (in terms of the Action API, action=paraminfo and action=help). It's replaced by two methods that each serve one of the use cases. Also some of the functionality was moved out of the TypeDef base class into ParamValidator, to better match where the constants themselves live. Also I wound up creating a NumericDef base class so FloatDef can share the same range-checking logic that IntegerDef has. I probably should have done that as a separate patch, but untangling it now would be too much work. Bug: T235801 Change-Id: Iea6d4a1d05bb4b92d60415b0f03ff9d3dc99a80b
* Use TextFormatter in the REST APITim Starling2019-09-171-2/+9
| | | | | | | | | | | | | * Add ResponseFactory::createLocalizedHttpError(), which generates a JSON response body from a MessageValue * ResponseFactory::__construct() accepts an array of TextFormatter objects. For ease of testing, the array may be empty. The integrated ResponseFactory has a TextFormatter for English, and one for $wgContLang if that is different. * Use createLocalizedHttpError() to show helpful error messages for errors generated by Router. Change-Id: I897a0aee42227916c568333ab384966f1b87f599
* MessageFormatterFactoryTim Starling2019-08-281-0/+11
An injectable service interface for message formatting, somewhat narrowed compared to Message. Only the text format is implemented in this framework so far, with getTextFormatter() returning a formatter that converts to the text format. Other formatters could be added to MessageFormatterFactory. Bug: T226598 Change-Id: Id053074c1dbcb692e8309fdca602f94a385bca0c