add exception management, correct mistakes in error management in Image.php and add function to simplify parameters using in tests

This commit is contained in:
Yoggzo 2016-03-17 11:34:56 +01:00
parent e01936a73e
commit fe0eb3a9e2
4 changed files with 338 additions and 289 deletions

View file

@ -89,10 +89,16 @@ class AppTest{
} }
public function getPostParam($name){ public function getPostParam($name){
return $this->postParams[$name]; return $this->postParams[$name];
} }
public function setPostParam($name, $value){
$this->postParams[$name] = $value;
}
public function setOutput($key, $out){ public function setOutput($key, $out){

View file

@ -14,55 +14,39 @@ $opt['minDisk'] = 1;
$opt['protected'] = false; $opt['protected'] = false;
$opt['minRam'] = 10; $opt['minRam'] = 10;
//$new_image = $image->createImage($opt); //$App->setPostParam('id', 'sdfihlus154dfhj');
$err = $image->action("createImage");
//Liste des images //Liste des images
$image->action("listImage"); $image->action("listImage");
//$images = $image->listImage();
$im = $App->show(); $im = $App->show();
$images = json_decode($im, true)["Images"]; $images = json_decode($im, true)["Images"];
if(isset($images)){ $recup;
echo "Images présentes :";
echo "Images présentes :";
echo "</br>";
foreach($images as $i){
$recup = $i;
echo $recup['name'];
echo "</br>"; echo "</br>";
foreach($images as $i){ //echo $recup['id'];
echo $i['name']; }
echo "</br>"; echo "</br>";
} echo "Erreur capturée: ";
echo "</br>"; echo "</br>";
if(isset($list)){ /*
foreach ($list as $l) { //$App->setPostParam('id', $recup['id']);
echo $l; $App->setPostParam('id', 'sdfihlus154dfhj');
echo "</br>"; $err = $image->action("detailsImage");
} $temp = $App->show();
} $ret = json_decode($temp, true)["Images"];
} echo $ret['id'];
else{ */
echo "Aucune image présente\n"; //$App->getPostParam("id");
}
// Détails Image
//$details = $image->imageDetails($id_image);
//$image->deleteImage('123456');
//$image->desactivateImage($id_image);
//$image->reactivateImage($id_image);
//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
//$image->uploadImage($id_image, $file_name);
//$image->downloadImage($id_image);
/*
$opt_update = Array();
$opt_update['name'] = "Test";
$opt_update['tags'] = null;
$update = $image->updateImage($id_image, $opt_update);
echo $update->name;
*/
?> ?>

View file

@ -32,6 +32,10 @@ Class errorManagement{
public function UserInputHandler($error){ public function UserInputHandler($error){
} }
public function OtherException($error){
$this->app->setOutput("Error", $error->getMessage);
}
} }

View file

@ -131,6 +131,8 @@ class image implements Core{
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $image); $this->app->setOutput("Images", $image);
@ -156,6 +158,8 @@ class image implements Core{
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $result); $this->app->setOutput("Images", $result);
@ -171,26 +175,33 @@ class image implements Core{
*/ */
private function detailsImage(){ private function detailsImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter"); $this->app->setOutput("Error", "Incorrect id parameter");
} }
try{ else{
$service = $this->libClass; try{
$image = $service->getImage($id); $service = $this->libClass;
if($image == null){ // if the image don't exists -> error $image = $service->getImage($id);
$this->app->setOutput("Error", "Image doesn't exist"); if($image == null){ // if the image don't exists -> error
} $this->app->setOutput("Error", "Image doesn't exist");
$this->app->setOutput("Images", $image); }
}catch(BadResponseError $e){ else{
$this->app->getErrorInstance()->BadResponseHandler($e); echo 'toto';
}catch(UserInputError $e){ $this->app->setOutput("Images", $image);
$this->app->getErrorInstance()->UserInputHandler($e); }
}catch(BaseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(NotImplementedError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
/** /**
@ -209,50 +220,53 @@ class image implements Core{
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter"); $this->app->setOutput("Error", "Incorrect id parameter");
} }
if(!isset($opt)){ else if(!isset($opt)){
$this->app->setOutput("Error", "Incorrect opt parameter"); $this->app->setOutput("Error", "Incorrect opt parameter");
} }
else{
try{
//vérifier existence image
$service = $this->libClass;
$image = $service->getImage($id);
if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist");
}
try{ $options = Array();
//vérifier existence image
$service = $this->libClass;
$image = $service->getImage($id);
if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist");
}
$options = Array(); // Voir vérification des types
if(isset($opt['name'])){ //string
// Voir vérification des types $options['name'] = $opt['name'];
if(isset($opt['name'])){ //string }
$options['name'] = $opt['name']; if(isset($opt['minDisk'])){ //int
} $options['minDisk'] = $opt['minDisk'];
if(isset($opt['minDisk'])){ //int }
$options['minDisk'] = $opt['minDisk']; if(isset($opt['minRam'])){ // int
} $options['minRam'] = $opt['minRam'];
if(isset($opt['minRam'])){ // int }
$options['minRam'] = $opt['minRam']; if(isset($opt['protected'])){ // boolean
} $options['protected'] = $opt['protected'];
if(isset($opt['protected'])){ // boolean }
$options['protected'] = $opt['protected']; if(isset($opt['visibility'])){ // public, private
} $options['visibility'] = $opt['visibility'];
if(isset($opt['visibility'])){ // public, private }
$options['visibility'] = $opt['visibility']; if(isset($opt['tags'])){ // list
} $options['tags'] = $opt['tags'];
if(isset($opt['tags'])){ // list }
$options['tags'] = $opt['tags']; $image->update($options);
} }catch(BadResponseError $e){
$image->update($options); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(BadResponseError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(UserInputError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(BaseError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(NotImplementedError $e){ }catch(Exception $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $image); $this->app->setOutput("Images", $image);
}
} }
/** /**
@ -269,23 +283,26 @@ class image implements Core{
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Image doesn't exist"); $this->app->setOutput("Error", "Image doesn't exist");
} }
else{
try{ try{
$service = $this->libClass; $service = $this->libClass;
$image = $this->libClass->getImage($id); $image = $this->libClass->getImage($id);
if($image == null){ // if the image doesn't exists -> error if($image == null){ // if the image doesn't exists -> error
$this->app->setOutput("Error", "Image doesn't exist"); $this->app->setOutput("Error", "Image doesn't exist");
} }
$image->delete(); $image->delete();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
/** /**
@ -301,22 +318,27 @@ class image implements Core{
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect parameter"); $this->app->setOutput("Error", "Incorrect parameter");
} }
try{ else
$service = $this->libClass; {
$image = $service->getImage($id); try{
if($image == null){ // if the image don't exists -> error $service = $this->libClass;
$this->app->setOutput("Error", "Image doesn't exist"); $image = $service->getImage($id);
} if($image == null){ // if the image don't exists -> error
$image->reactivate(); $this->app->setOutput("Error", "Image doesn't exist");
}catch(BadResponseError $e){ }
$this->app->getErrorInstance()->BadResponseHandler($e); $image->reactivate();
}catch(UserInputError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(BaseError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(NotImplementedError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
/** /**
@ -332,23 +354,28 @@ class image implements Core{
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect parameter"); $this->app->setOutput("Error", "Incorrect parameter");
} }
try{ else
// vérifier existence image {
$service = $this->libClass; try{
$image = $service->getImage($id); // vérifier existence image
if($image == null){ // if the image don't exists -> error $service = $this->libClass;
$this->app->setOutput("Error", "Image doesn't exist"); $image = $service->getImage($id);
} if($image == null){ // if the image don't exists -> error
$image->deactivate(); $this->app->setOutput("Error", "Image doesn't exist");
}catch(BadResponseError $e){ }
$this->app->getErrorInstance()->BadResponseHandler($e); $image->deactivate();
}catch(UserInputError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(BaseError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(NotImplementedError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
/** /**
@ -367,26 +394,30 @@ class image implements Core{
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter"); $this->app->setOutput("Error", "Incorrect id parameter");
} }
if(!isset($file_name)){ else if(!isset($file_name)){
$this->app->setOutput("Error", "Incorrect file name parameter"); $this->app->setOutput("Error", "Incorrect file name parameter");
} }
try{ else{
// vérifier existence image try{
$service = $this->libClass; // vérifier existence image
$image = $service->getImage($id); $service = $this->libClass;
if($image == null){ // if the image don't exists -> error $image = $service->getImage($id);
$this->app->setOutput("Error", "Image doesn't exist"); if($image == null){ // if the image don't exists -> error
} $this->app->setOutput("Error", "Image doesn't exist");
$stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); }
$image->uploadData($stream); $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r'));
}catch(BadResponseError $e){ $image->uploadData($stream);
$this->app->getErrorInstance()->BadResponseHandler($e); }catch(BadResponseError $e){
}catch(UserInputError $e){ $this->app->getErrorInstance()->BadResponseHandler($e);
$this->app->getErrorInstance()->UserInputHandler($e); }catch(UserInputError $e){
}catch(BaseError $e){ $this->app->getErrorInstance()->UserInputHandler($e);
$this->app->getErrorInstance()->BaseErrorHandler($e); }catch(BaseError $e){
}catch(NotImplementedError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e);
$this->app->getErrorInstance()->NotImplementedHandler($e); }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
} }
} }
@ -403,24 +434,28 @@ class image implements Core{
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter"); $this->app->setOutput("Error", "Incorrect id parameter");
} }
try{ else{
// vérifier existence image try{
$service = $this->libClass; // vérifier existence image
$image = $service->getImage($id); $service = $this->libClass;
if($image == null){ // if the image don't exists -> error $image = $service->getImage($id);
$this->app->setOutput("Error", "Image doesn't exist"); if($image == null){ // if the image don't exists -> error
} $this->app->setOutput("Error", "Image doesn't exist");
$stream = $image->downloadData(); }
}catch(BadResponseError $e){ $stream = $image->downloadData();
$this->app->getErrorInstance()->BadResponseHandler($e); }catch(BadResponseError $e){
}catch(UserInputError $e){ $this->app->getErrorInstance()->BadResponseHandler($e);
$this->app->getErrorInstance()->UserInputHandler($e); }catch(UserInputError $e){
}catch(BaseError $e){ $this->app->getErrorInstance()->UserInputHandler($e);
$this->app->getErrorInstance()->BaseErrorHandler($e); }catch(BaseError $e){
}catch(NotImplementedError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e);
$this->app->getErrorInstance()->NotImplementedHandler($e); }catch(NotImplementedError $e){
} $this->app->getErrorInstance()->NotImplementedHandler($e);
$this->app->setOutput("Images", $stream); }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
$this->app->setOutput("Images", $stream);
}
} }
/** /**
@ -438,27 +473,31 @@ class image implements Core{
if(!isset($image_id)){ if(!isset($image_id)){
$this->app->setOutput("Error", "Incorrect image id parameter"); $this->app->setOutput("Error", "Incorrect image id parameter");
} }
if(!isset($member_id)){ else if(!isset($member_id)){
$this->app->setOutput("Error", "Incorrect member id parameter"); $this->app->setOutput("Error", "Incorrect member id parameter");
} }
try{ else{
$service = $this->libClass; try{
$service = $this->libClass;
$image = $service->getImage($id); $image = $service->getImage($id);
if($image == null){ // if the image don't exists -> error if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist"); $this->app->setOutput("Error", "Image doesn't exist");
} }
$member_id = $image->addMember($member_id); $member_id = $image->addMember($member_id);
$this->app->setOutput("Images", $member_id); $this->app->setOutput("Images", $member_id);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
@ -476,30 +515,34 @@ class image implements Core{
if(!isset($image_id)){ if(!isset($image_id)){
$this->app->setOutput("Error", "Incorrect image id parameter"); $this->app->setOutput("Error", "Incorrect image id parameter");
} }
if(!isset($member_id)){ else if(!isset($member_id)){
$this->app->setOutput("Error", "Incorrect member id parameter"); $this->app->setOutput("Error", "Incorrect member id parameter");
} }
try{ else{
// vérifier existence image try{
$service = $this->libClass; // vérifier existence image
$image = $service->getImage($image_id); $service = $this->libClass;
if($image == null){ // if the image don't exists -> error $image = $service->getImage($image_id);
$this->app->setOutput("Error", "Image doesn't exist"); if($image == null){ // if the image don't exists -> error
} $this->app->setOutput("Error", "Image doesn't exist");
$members = $image->listMembers(); }
if($members == null){ // if the image don't exists -> error $members = $image->listMembers();
$this->app->setOutput("Error", "No member"); if($members == null){ // if the image don't exists -> error
} $this->app->setOutput("Error", "No member");
}catch(BadResponseError $e){ }
$this->app->getErrorInstance()->BadResponseHandler($e); }catch(BadResponseError $e){
}catch(UserInputError $e){ $this->app->getErrorInstance()->BadResponseHandler($e);
$this->app->getErrorInstance()->UserInputHandler($e); }catch(UserInputError $e){
}catch(BaseError $e){ $this->app->getErrorInstance()->UserInputHandler($e);
$this->app->getErrorInstance()->BaseErrorHandler($e); }catch(BaseError $e){
}catch(NotImplementedError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e);
$this->app->getErrorInstance()->NotImplementedHandler($e); }catch(NotImplementedError $e){
} $this->app->getErrorInstance()->NotImplementedHandler($e);
$this->app->setOutput("Images", $members); }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
$this->app->setOutput("Images", $members);
}
} }
/** /**
@ -517,31 +560,35 @@ class image implements Core{
if(!isset($image_id)){ if(!isset($image_id)){
$this->app->setOutput("Error", "Incorrect image id parameter"); $this->app->setOutput("Error", "Incorrect image id parameter");
} }
if(!isset($member_id)){ else if(!isset($member_id)){
$this->app->setOutput("Error", "Incorrect member id parameter"); $this->app->setOutput("Error", "Incorrect member id parameter");
} }
try{ else{
$service = $this->libClass; try{
$service = $this->libClass;
$image = $service->getImage($id); $image = $service->getImage($id);
if($image == null){ // if the image don't exists -> error if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist"); $this->app->setOutput("Error", "Image doesn't exist");
} }
$member = $image->getMember($member_id); $member = $image->getMember($member_id);
if($member == null){ // if the member don't exists -> error if($member == null){ // if the member don't exists -> error
$this->app->setOutput("Error", "Member doesn't exist"); $this->app->setOutput("Error", "Member doesn't exist");
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }catch(Exception $e){
$this->app->setOutput("Images", $member); $this->app->getErrorInstance()->OtherException($e);
}
$this->app->setOutput("Images", $member);
}
} }
/** /**
@ -559,30 +606,34 @@ class image implements Core{
if(!isset($image_id)){ if(!isset($image_id)){
$this->app->setOutput("Error", "Incorrect image id parameter"); $this->app->setOutput("Error", "Incorrect image id parameter");
} }
if(!isset($member_id)){ else if(!isset($member_id)){
$this->app->setOutput("Error", "Incorrect member id parameter"); $this->app->setOutput("Error", "Incorrect member id parameter");
} }
try{ else{
$service = $this->libClass; try{
$service = $this->libClass;
$image = $service->getImage($id); $image = $service->getImage($id);
if($image == null){ // if the image don't exists -> error if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist"); $this->app->setOutput("Error", "Image doesn't exist");
} }
$member = $image->getMember($member_id); $member = $image->getMember($member_id);
if($member == null){ // if the image don't exists -> error if($member == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Member doesn't exist"); $this->app->setOutput("Error", "Member doesn't exist");
} }
$member->delete(); $member->delete();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
/** /**
@ -602,30 +653,34 @@ class image implements Core{
if(!isset($image_id)){ if(!isset($image_id)){
$this->app->setOutput("Error", "Incorrect image id parameter"); $this->app->setOutput("Error", "Incorrect image id parameter");
} }
if(!isset($member_id)){ else if(!isset($member_id)){
$this->app->setOutput("Error", "Incorrect member id parameter"); $this->app->setOutput("Error", "Incorrect member id parameter");
} }
try{ else{
$service = $this->libClass; try{
$service = $this->libClass;
$image = $service->getImage($id); $image = $service->getImage($id);
if($image == null){ // if the image don't exists -> error if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist"); $this->app->setOutput("Error", "Image doesn't exist");
} }
$member = $image->getMember($member_id); $member = $image->getMember($member_id);
if($member == null){ // if the member don't exists -> error if($member == null){ // if the member don't exists -> error
$this->app->setOutput("Error", "Member doesn't exist"); $this->app->setOutput("Error", "Member doesn't exist");
} }
$member->updateStatus($status); $member->updateStatus($status);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
} }
} }