diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-28 12:17:43 +0200 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-28 12:17:43 +0200 |
| commit | 53f65de9d4163c9c095f2b8e87baca648c3645bd (patch) | |
| tree | 37f167f38b25aa50bd7dd1429438c0245a280a28 /server/core/ErrorManagement.php | |
| parent | 60cfe3ebc039df8d6a468a43a59e7fd8c2a16956 (diff) | |
| parent | 804fa322d841d73ee7592885ec500dc94e91b9e6 (diff) | |
Test
Diffstat (limited to 'server/core/ErrorManagement.php')
| -rwxr-xr-x | server/core/ErrorManagement.php | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index ff66339..be7080b 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -1,4 +1,13 @@ <?php
+/**
+* File containing the Errormanagement Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr', Evan Pisani 'yogg at epsina . com'
+*
+*/
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
@@ -7,37 +16,106 @@ use OpenCloud\Common\Error\UserInputError; Class errorManagement{
-
+ /** @var App $app protected, contains the main app object */
protected $app;
-
+ /**
+ * ErrorManagemement constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return ErrorManagement
+ */
public function __construct($args){
$this->app = $args;
}
+ /**
+ * Put an error message corresponding to a base error in the output
+ *
+ * @param $error the error triggered
+ *
+ * @return String BaseError message
+ */
public function BaseErrorHandler($error){
-
+ $this->app->setOutput("Error", "BaseError");
}
+ /**
+ * Put an error message corresponding to a bad response in function of the status code in the output
+ *
+ * @param $error the error triggered
+ *
+ * @return String Error message
+ */
public function BadResponseHandler($error){
- $this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!");
+ $statusCode = $error->getResponse()->getStatusCode();
+ switch ($statusCode) {
+ case 400:
+ $this->app->setOutput("Error", "Invalid input.");
+ break;
+
+ case 401:
+ $this->app->setOutput("Error", "Authentification failed.");
+ break;
+
+ case 403:
+ $this->app->setOutput("Error", "Operation forbidden.");
+ break;
+
+ case 404:
+ $this->app->setOutput("Error", "Ressource not found.");
+ break;
+
+ case 500:
+ $this->app->setOutput("Error", "Internal server error, please contact an administrator.");
+ break;
+
+ case 503:
+ $this->app->setOutput("Error", "Service unvailable for the moment.");
+ break;
+
+ default:
+ $this->app->setOutput("Error", "Unknow error, please contact an administrator.");
+ break;
+ }
}
+ /**
+ * Put an error message corresponding to a not implemented yet error in the output
+ *
+ * @param $error the error triggered
+ *
+ * @return String internal error message
+ */
public function NotImplementedHandler($error){
- $this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!");
+ $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator");
}
+ /**
+ * Put an error message corresponding to a user input error in the output
+ *
+ * @param $error the error triggered
+ *
+ * @return String User input error message
+ */
public function UserInputHandler($error){
-
+ $this->app->setOutput("Error", "UserInputError");
}
+ /**
+ * Put an error message corresponding to an other error in the output
+ *
+ * @param $error the error triggered
+ *
+ * @return String error message
+ */
public function OtherException($error){
- $this->app->setOutput("Error", $error->getMessage);
+ $this->app->setOutput("Error", $error->getMessage());
}
-
}
?>
|
