Added management of exception_mode

This commit is contained in:
xdrm-brackets 2017-09-19 21:22:09 +02:00
parent d8c2e7c2bf
commit c0c26e6cb9
1 changed files with 18 additions and 1 deletions

View File

@ -7,9 +7,17 @@
class Error{
private static $exception_mode = false;
private $error = null;
private $args = [];
// set exception mode
public static function setExceptionMode($exception=false){
self::$exception_mode = $exception;
}
/* ERROR CONSTRUCTOR
*
* @error<const> Const error
@ -38,7 +46,7 @@
* @arg2<String> [OPT] Argument 2
* @arg...<String> [OPT] Argument ...
*
* @return instance<Error> Error instance
* @return FALSE
*
*/
public function set($const){
@ -49,6 +57,15 @@
/* (2) On récupère les arguments */
$this->args = array_slice(func_get_args(), 1);
/* [2] Si mode exception -> lève une exception
=========================================================*/
if( $this->error !== Err::Success && self::$exception_mode )
throw new \Exception($this->explicit(), $this->error);
return false;
}