aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiUsageException.php
diff options
context:
space:
mode:
authorBrad Jorsch <bjorsch@wikimedia.org>2016-12-08 13:38:45 -0500
committerBrad Jorsch <bjorsch@wikimedia.org>2016-12-08 13:53:24 -0500
commita90bbf1a484c9d22cb04770e92ce18fe3e4bf398 (patch)
tree0c554de7c11891a7b83d86cb549bc4d136d15fe9 /includes/api/ApiUsageException.php
parent20f0da437eeed7e8ca28be911f53535be82889a1 (diff)
downloadmediawikicore-a90bbf1a484c9d22cb04770e92ce18fe3e4bf398.tar.gz
mediawikicore-a90bbf1a484c9d22cb04770e92ce18fe3e4bf398.zip
Add ILocalizedException interface
We already throw around some exceptions that are localized (ErrorPageError and its subclasses, MalformedTitleException), but there's no standard way to recognize them. Let's change that. Then let's use them in the API to be able to have internationalized errors when such exceptions are caught, instead of wrapping the English-language version. Change-Id: Iac7c90f92a889f8de9dae373547c07b884addaea
Diffstat (limited to 'includes/api/ApiUsageException.php')
-rw-r--r--includes/api/ApiUsageException.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/includes/api/ApiUsageException.php b/includes/api/ApiUsageException.php
index 7e21ab5ba446..9dc1f92bbc7d 100644
--- a/includes/api/ApiUsageException.php
+++ b/includes/api/ApiUsageException.php
@@ -95,7 +95,7 @@ class UsageException extends MWException {
* starts throwing ApiUsageException. Eventually UsageException will go away
* and this will (probably) extend MWException directly.
*/
-class ApiUsageException extends UsageException {
+class ApiUsageException extends UsageException implements ILocalizedException {
protected $modulePath;
protected $status;
@@ -202,6 +202,13 @@ class ApiUsageException extends UsageException {
}
/**
+ * @inheritdoc
+ */
+ public function getMessageObject() {
+ return $this->status->getMessage();
+ }
+
+ /**
* @return string
*/
public function __toString() {