aboutsummaryrefslogtreecommitdiff
path: root/lib/minz/exceptions/MinzException.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-07-04 19:38:29 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-07-04 19:38:29 +0200
commiteb5f05304c253df90873b94ba52d7093115f3850 (patch)
tree1152ab618aa5cf884a1f2f2e2d1926da4167a6be /lib/minz/exceptions/MinzException.php
parent8dd5fd51f74a47e5c80052f27a74cdcd5dd044b9 (diff)
parentb5f233f6d524ca9f74e9d33bf5692a1a678d7fec (diff)
Merge branch 'dev'0.4.0
Diffstat (limited to 'lib/minz/exceptions/MinzException.php')
-rw-r--r--lib/minz/exceptions/MinzException.php94
1 files changed, 94 insertions, 0 deletions
diff --git a/lib/minz/exceptions/MinzException.php b/lib/minz/exceptions/MinzException.php
new file mode 100644
index 000000000..8fca5ec16
--- /dev/null
+++ b/lib/minz/exceptions/MinzException.php
@@ -0,0 +1,94 @@
+<?php
+
+class MinzException extends Exception {
+ const ERROR = 0;
+ const WARNING = 10;
+ const NOTICE = 20;
+
+ public function __construct ($message, $code = self::ERROR) {
+ if ($code != MinzException::ERROR
+ && $code != MinzException::WARNING
+ && $code != MinzException::NOTICE) {
+ $code = MinzException::ERROR;
+ }
+
+ parent::__construct ($message, $code);
+ }
+}
+
+class PermissionDeniedException extends MinzException {
+ public function __construct ($file_name, $code = self::ERROR) {
+ $message = 'Permission is denied for `' . $file_name.'`';
+
+ parent::__construct ($message, $code);
+ }
+}
+class FileNotExistException extends MinzException {
+ public function __construct ($file_name, $code = self::ERROR) {
+ $message = 'File doesn\'t exist : `' . $file_name.'`';
+
+ parent::__construct ($message, $code);
+ }
+}
+class BadConfigurationException extends MinzException {
+ public function __construct ($part_missing, $code = self::ERROR) {
+ $message = '`' . $part_missing
+ . '` in the configuration file is missing';
+
+ parent::__construct ($message, $code);
+ }
+}
+class ControllerNotExistException extends MinzException {
+ public function __construct ($controller_name, $code = self::ERROR) {
+ $message = 'Controller `' . $controller_name
+ . '` doesn\'t exist';
+
+ parent::__construct ($message, $code);
+ }
+}
+class ControllerNotActionControllerException extends MinzException {
+ public function __construct ($controller_name, $code = self::ERROR) {
+ $message = 'Controller `' . $controller_name
+ . '` isn\'t instance of ActionController';
+
+ parent::__construct ($message, $code);
+ }
+}
+class ActionException extends MinzException {
+ public function __construct ($controller_name, $action_name, $code = self::ERROR) {
+ $message = '`' . $action_name . '` cannot be invoked on `'
+ . $controller_name . '`';
+
+ parent::__construct ($message, $code);
+ }
+}
+class RouteNotFoundException extends MinzException {
+ private $route;
+
+ public function __construct ($route, $code = self::ERROR) {
+ $this->route = $route;
+
+ $message = 'Route `' . $route . '` not found';
+
+ parent::__construct ($message, $code);
+ }
+
+ public function route () {
+ return $this->route;
+ }
+}
+class PDOConnectionException extends MinzException {
+ public function __construct ($string_connection, $user, $code = self::ERROR) {
+ $message = 'Access to database is denied for `' . $user . '`'
+ . ' (`' . $string_connection . '`)';
+
+ parent::__construct ($message, $code);
+ }
+}
+class CurrentPagePaginationException extends MinzException {
+ public function __construct ($page) {
+ $message = 'Page number `' . $page . '` doesn\'t exist';
+
+ parent::__construct ($message, self::ERROR);
+ }
+}