132 lines
3.9 KiB
PHP
Executable File
132 lines
3.9 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
namespace manager;
|
|
|
|
|
|
class ManagerError{
|
|
|
|
/* SUCCESS */
|
|
const Success = 0;
|
|
|
|
/* Parsage json */
|
|
const ParsingFailed = 1;
|
|
|
|
/* ResourceDispatcher */
|
|
|
|
// Drapeaux invalides
|
|
const InvalidFlags = 2;
|
|
|
|
// Fichier inexistant
|
|
const UnreachableResource = 3;
|
|
|
|
|
|
/* ModuleRequest */
|
|
|
|
// Le @path n'est pas renseigne
|
|
const MissingPath = 4;
|
|
|
|
// Verification de la coherence du chemin (existe dans la conf)
|
|
const WrongPathModule = 5;
|
|
|
|
// Module non specifie dans la conf
|
|
const UnknownModule = 6;
|
|
|
|
// Methode non specifie pour ce Module dans la conf
|
|
const UnknownMethod = 7;
|
|
|
|
// Methode inamorcable
|
|
const UncallableMethod = 8;
|
|
|
|
// Erreur de parametre(s)
|
|
const ParamError = 9;
|
|
|
|
// Erreur dans le traitement
|
|
const ModuleError = 10;
|
|
|
|
/* Repo */
|
|
|
|
// Verification de la coherence du chemin (existe dans la conf)
|
|
const WrongPathRepo = 11;
|
|
|
|
// Module non specifie dans la conf
|
|
const UnknownRepo = 12;
|
|
|
|
// Erreur dans le traitement
|
|
const RepoError = 13;
|
|
|
|
/* Database */
|
|
|
|
// Erreur lors de la creation d'un objet PDO (connection)
|
|
const PDOConnection = 14;
|
|
|
|
/* API token */
|
|
// Token inexistant ou faux
|
|
const TokenError = 15;
|
|
|
|
const PermissionError = 16;
|
|
|
|
/* Erreur d'UPLOAD */
|
|
const UploadError = 17;
|
|
|
|
// Mauvais format de fichier
|
|
const FormatError = 18;
|
|
|
|
/* Erreur au niveau javascript */
|
|
//const JavascriptError = 19; // -> géré en js
|
|
|
|
// Already done error
|
|
const Already = 20;
|
|
|
|
|
|
/* EXPLICITE UN CODE D'ERREUR
|
|
*
|
|
* @error<Integer> Code d'erreur
|
|
*
|
|
* @return explicit<String> Description explicite du code d'erreur
|
|
*
|
|
*/
|
|
public static function explicit($error){
|
|
switch($error){
|
|
case self::Success: return "All right."; break;
|
|
|
|
case self::ParsingFailed: return "JSON/XML file format error."; break;
|
|
|
|
case self::InvalidFlags: return "Flags are incorrect."; break;
|
|
case self::UnreachableResource: return "Resource unreachable (404)."; break;
|
|
case self::MissingPath: return "Path missing."; break;
|
|
case self::WrongPathModule: return "Module path incorrect 'module/method'."; break;
|
|
case self::WrongPathRepo: return "Repository path incorrect 'repo/method'."; break;
|
|
case self::UnknownModule: return "Requested module not found."; break;
|
|
case self::UnknownRepo: return "Requested repository not found."; break;
|
|
case self::UnknownMethod: return "Requested method not found."; break;
|
|
case self::UncallableMethod: return "Cannot call requested method."; break;
|
|
|
|
case self::ParamError: return "Wrong or missing parameter(s)."; break;
|
|
case self::ModuleError: return "Module error."; break;
|
|
case self::RepoError: return "Repository error."; break;
|
|
|
|
case self::PDOConnection: return "Database connection failed."; break;
|
|
|
|
case self::TokenError: return "Access token wrong, missing or expired."; break;
|
|
case self::PermissionError: return "Not granted to do so."; break;
|
|
case self::UploadError: return "Upload error."; break;
|
|
case self::FormatError: return "Format error."; break;
|
|
case self::Already: return "Already done."; break;
|
|
|
|
default: return "Unknown debug error"; break;
|
|
}
|
|
|
|
// Erreur inconnue
|
|
return null;
|
|
}
|
|
|
|
|
|
public static function setHttpCode($error){
|
|
http_response_code( $error == self::Success ? 200 : 417 );
|
|
}
|
|
|
|
}
|
|
|
|
?>
|