72 lines
1.6 KiB
PHP
Executable file
72 lines
1.6 KiB
PHP
Executable file
<?php
|
|
|
|
use OpenCloud\Common\Error\BadResponseError;
|
|
use OpenCloud\Common\Error\BaseError;
|
|
use OpenCloud\Common\Error\NotImplementedError;
|
|
use OpenCloud\Common\Error\UserInputError;
|
|
|
|
|
|
Class errorManagement{
|
|
|
|
protected $app;
|
|
|
|
|
|
public function __construct($args){
|
|
|
|
$this->app = $args;
|
|
|
|
}
|
|
|
|
public function BaseErrorHandler($error){
|
|
$this->app->setOutput("Error", "BaseError");
|
|
}
|
|
|
|
public function BadResponseHandler($error){
|
|
$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;
|
|
}
|
|
}
|
|
|
|
public function NotImplementedHandler($error){
|
|
$this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator");
|
|
}
|
|
|
|
public function UserInputHandler($error){
|
|
$this->app->setOutput("Error", "UserInputError");
|
|
}
|
|
|
|
public function OtherException($error){
|
|
$this->app->setOutput("Error", $error->getMessage());
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|