about summary refs log tree commit diff stats
path: root/wiki/inc/Action/Exception
diff options
context:
space:
mode:
Diffstat (limited to 'wiki/inc/Action/Exception')
-rw-r--r--wiki/inc/Action/Exception/ActionAbort.php20
-rw-r--r--wiki/inc/Action/Exception/ActionAclRequiredException.php17
-rw-r--r--wiki/inc/Action/Exception/ActionDisabledException.php17
-rw-r--r--wiki/inc/Action/Exception/ActionException.php66
-rw-r--r--wiki/inc/Action/Exception/ActionUserRequiredException.php17
-rw-r--r--wiki/inc/Action/Exception/FatalException.php29
-rw-r--r--wiki/inc/Action/Exception/NoActionException.php15
7 files changed, 181 insertions, 0 deletions
diff --git a/wiki/inc/Action/Exception/ActionAbort.php b/wiki/inc/Action/Exception/ActionAbort.php
new file mode 100644
index 0000000..9c188bb
--- /dev/null
+++ b/wiki/inc/Action/Exception/ActionAbort.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class ActionAbort
+ *
+ * Strictly speaking not an Exception but an expected execution path. Used to
+ * signal when one action is done and another should take over.
+ *
+ * If you want to signal the same but under some error condition use ActionException
+ * or one of it's decendants.
+ *
+ * The message will NOT be shown to the enduser
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class ActionAbort extends ActionException {
+
+}
diff --git a/wiki/inc/Action/Exception/ActionAclRequiredException.php b/wiki/inc/Action/Exception/ActionAclRequiredException.php
new file mode 100644
index 0000000..64a2c61
--- /dev/null
+++ b/wiki/inc/Action/Exception/ActionAclRequiredException.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class ActionAclRequiredException
+ *
+ * Thrown by AbstractACLAction when an action requires that the ACL subsystem is
+ * enabled but it isn't. You should not use it
+ *
+ * The message will NOT be shown to the enduser
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class ActionAclRequiredException extends ActionException {
+
+}
diff --git a/wiki/inc/Action/Exception/ActionDisabledException.php b/wiki/inc/Action/Exception/ActionDisabledException.php
new file mode 100644
index 0000000..40a0c7d
--- /dev/null
+++ b/wiki/inc/Action/Exception/ActionDisabledException.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class ActionDisabledException
+ *
+ * Thrown when the requested action has been disabled. Eg. through the 'disableactions'
+ * config setting. You should probably not use it.
+ *
+ * The message will NOT be shown to the enduser, but a generic information will be shown.
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class ActionDisabledException extends ActionException {
+
+}
diff --git a/wiki/inc/Action/Exception/ActionException.php b/wiki/inc/Action/Exception/ActionException.php
new file mode 100644
index 0000000..381584c
--- /dev/null
+++ b/wiki/inc/Action/Exception/ActionException.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class ActionException
+ *
+ * This exception and its subclasses signal that the current action should be
+ * aborted and a different action should be used instead. The new action can
+ * be given as parameter in the constructor. Defaults to 'show'
+ *
+ * The message will NOT be shown to the enduser
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class ActionException extends \Exception {
+
+    /** @var string the new action */
+    protected $newaction;
+
+    /** @var bool should the exception's message be shown to the user? */
+    protected $displayToUser = false;
+
+    /**
+     * ActionException constructor.
+     *
+     * When no new action is given 'show' is assumed. For requests that originated in a POST,
+     * a 'redirect' is used which will cause a redirect to the 'show' action.
+     *
+     * @param string|null $newaction the action that should be used next
+     * @param string $message optional message, will not be shown except for some dub classes
+     */
+    public function __construct($newaction = null, $message = '') {
+        global $INPUT;
+        parent::__construct($message);
+        if(is_null($newaction)) {
+            if(strtolower($INPUT->server->str('REQUEST_METHOD')) == 'post') {
+                $newaction = 'redirect';
+            } else {
+                $newaction = 'show';
+            }
+        }
+
+        $this->newaction = $newaction;
+    }
+
+    /**
+     * Returns the action to use next
+     *
+     * @return string
+     */
+    public function getNewAction() {
+        return $this->newaction;
+    }
+
+    /**
+     * Should this Exception's message be shown to the user?
+     *
+     * @param null|bool $set when null is given, the current setting is not changed
+     * @return bool
+     */
+    public function displayToUser($set = null) {
+        if(!is_null($set)) $this->displayToUser = $set;
+        return $set;
+    }
+}
diff --git a/wiki/inc/Action/Exception/ActionUserRequiredException.php b/wiki/inc/Action/Exception/ActionUserRequiredException.php
new file mode 100644
index 0000000..aab06cc
--- /dev/null
+++ b/wiki/inc/Action/Exception/ActionUserRequiredException.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class ActionUserRequiredException
+ *
+ * Thrown by AbstractUserAction when an action requires that a user is logged
+ * in but it isn't. You should not use it.
+ *
+ * The message will NOT be shown to the enduser
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class ActionUserRequiredException extends ActionException {
+
+}
diff --git a/wiki/inc/Action/Exception/FatalException.php b/wiki/inc/Action/Exception/FatalException.php
new file mode 100644
index 0000000..5f2516f
--- /dev/null
+++ b/wiki/inc/Action/Exception/FatalException.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class FatalException
+ *
+ * A fatal exception during handling the action
+ *
+ * Will abort all handling and display some info to the user. The HTTP status code
+ * can be defined.
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class FatalException extends \Exception {
+
+    protected $status;
+
+    /**
+     * FatalException constructor.
+     *
+     * @param string $message the message to send
+     * @param int $status the HTTP status to send
+     * @param null|\Exception $previous previous exception
+     */
+    public function __construct($message = 'A fatal error occured', $status = 500, $previous = null) {
+        parent::__construct($message, $status, $previous);
+    }
+}
diff --git a/wiki/inc/Action/Exception/NoActionException.php b/wiki/inc/Action/Exception/NoActionException.php
new file mode 100644
index 0000000..1c4e4d0
--- /dev/null
+++ b/wiki/inc/Action/Exception/NoActionException.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace dokuwiki\Action\Exception;
+
+/**
+ * Class NoActionException
+ *
+ * Thrown in the ActionRouter when a wanted action can not be found. Triggers
+ * the unknown action event
+ *
+ * @package dokuwiki\Action\Exception
+ */
+class NoActionException extends \Exception {
+
+}