summaryrefslogtreecommitdiff
path: root/bin/wiki/vendor/addwiki/mediawiki-api-base/src/UsageException.php
diff options
context:
space:
mode:
Diffstat (limited to 'bin/wiki/vendor/addwiki/mediawiki-api-base/src/UsageException.php')
-rw-r--r--bin/wiki/vendor/addwiki/mediawiki-api-base/src/UsageException.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/bin/wiki/vendor/addwiki/mediawiki-api-base/src/UsageException.php b/bin/wiki/vendor/addwiki/mediawiki-api-base/src/UsageException.php
new file mode 100644
index 00000000..77148f1b
--- /dev/null
+++ b/bin/wiki/vendor/addwiki/mediawiki-api-base/src/UsageException.php
@@ -0,0 +1,75 @@
+<?php
+
+namespace Mediawiki\Api;
+
+use Exception;
+
+/**
+ * Class representing a Mediawiki Api UsageException
+ *
+ * @since 0.1
+ *
+ * @author Addshore
+ */
+class UsageException extends Exception {
+
+ /**
+ * @var string
+ */
+ private $apiCode;
+
+ /**
+ * @var array
+ */
+ private $result;
+
+ /**
+ * @var string
+ */
+ private $rawMessage;
+
+ /**
+ * @since 0.1
+ *
+ * @param string $apiCode The API error code.
+ * @param string $message The API error message.
+ * @param array $result the result the exception was generated from
+ */
+ public function __construct( $apiCode = '', $message = '', $result = [] ) {
+ $this->apiCode = $apiCode;
+ $this->result = $result;
+ $this->rawMessage = $message;
+ $message = 'Code: ' . $apiCode . PHP_EOL .
+ 'Message: ' . $message . PHP_EOL .
+ 'Result: ' . json_encode( $result );
+ parent::__construct( $message, 0, null );
+ }
+
+ /**
+ * @since 0.1
+ *
+ * @return string
+ */
+ public function getApiCode() {
+ return $this->apiCode;
+ }
+
+ /**
+ * @since 0.3
+ *
+ * @return array
+ */
+ public function getApiResult() {
+ return $this->result;
+ }
+
+ /**
+ * @since 2.3.0
+ *
+ * @return string
+ */
+ public function getRawMessage() {
+ return $this->rawMessage;
+ }
+
+}