Added error arguments to serialized version (json)

This commit is contained in:
xdrm-brackets 2017-09-18 18:01:31 +02:00
parent 9dbbc1e3dc
commit 2b698e56f5
2 changed files with 24 additions and 23 deletions

View File

@ -109,7 +109,8 @@
// On rajoute l'erreur au message
$returnData = array_merge([
'error' => $this->error->get(),
'ErrorDescription' => $this->error->explicit()
'ErrorDescription' => $this->error->explicit(),
'ErrorArguments' => $this->error->args()
],
$this->data
);

View File

@ -8,7 +8,7 @@
class Error{
private $error = null;
private $arguments = [];
private $args = [];
/* ERROR CONSTRUCTOR
*
@ -48,7 +48,7 @@
$this->error = !is_numeric($const) ? Err::UnknownError : $const;
/* (2) On récupère les arguments */
$this->arguments = array_slice(func_get_args(), 1);
$this->args = array_slice(func_get_args(), 1);
}
@ -98,8 +98,8 @@
private function Success(){
return 'all right';
}private function ParsingFailed(){
if( count($this->arguments) > 0 )
return "{$this->arguments[0]} parsing failed";
if( count($this->args) > 0 )
return "{$this->args[0]} parsing failed";
else
return 'parsing failed';
}private function UnreachableResource(){
@ -119,23 +119,23 @@
}private function WrongPathModule(){
return 'wrong module\'s path';
}private function UnknownModule(){
if( count($this->arguments) > 0 )
return "unknown module '{$this->arguments[0]}'";
if( count($this->args) > 0 )
return "unknown module '{$this->args[0]}'";
else
return 'unknown module';
}private function UnknownMethod(){
if( count($this->arguments) > 0 )
return "unknown method '{$this->arguments[0]}'";
if( count($this->args) > 0 )
return "unknown method '{$this->args[0]}'";
else
return 'unknown method';
}private function UncallableModule(){
if( count($this->arguments) > 0 )
return "uncallable module '{$this->arguments[0]}'";
if( count($this->args) > 0 )
return "uncallable module '{$this->args[0]}'";
else
return 'uncallable module';
}private function UncallableMethod(){
if( count($this->arguments) > 0 )
return "uncallable method '{$this->arguments[0]}'";
if( count($this->args) > 0 )
return "uncallable method '{$this->args[0]}'";
else
return 'uncallable method';
}private function UnknownHttpMethod(){
@ -143,16 +143,16 @@
}private function ConfigError(){
return 'configuration error';
}private function MissingParam(){
if( count($this->arguments) > 0 )
return "missing param '{$this->arguments[0]}'";
if( count($this->args) > 0 )
return "missing param '{$this->args[0]}'";
else
return 'missing param';
}private function WrongParam(){
if( count($this->arguments) > 0 )
if( count($this->arguments) > 1 )
return "wrong param '{$this->arguments[0]}' expected to be of type '{$this->arguments[1]}'";
if( count($this->args) > 0 )
if( count($this->args) > 1 )
return "wrong param '{$this->args[0]}' expected to be of type '{$this->args[1]}'";
else
return "wrong param '{$this->arguments[0]}'";
return "wrong param '{$this->args[0]}'";
else
return 'wrong param';
}private function ModuleError(){
@ -180,15 +180,15 @@
}private function UnknownDebugError(){
return 'unknown debug error';
}private function AlreadyExists(){
if( count($this->arguments) > 0 )
return "'{$this->arguments[0]}' already exists";
if( count($this->args) > 0 )
return "'{$this->args[0]}' already exists";
return 'entry already exists';
}
public function args(){
return $this->arguments;
return $this->args;
}