From c0c26e6cb9240e6bf1459bd26f7c690c6ca22088 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Sep 2017 21:22:09 +0200 Subject: [PATCH] Added management of exception_mode --- build/error/core/Error.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/build/error/core/Error.php b/build/error/core/Error.php index 745cd0c..01341d7 100644 --- a/build/error/core/Error.php +++ b/build/error/core/Error.php @@ -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 error @@ -38,7 +46,7 @@ * @arg2 [OPT] Argument 2 * @arg... [OPT] Argument ... * - * @return instance 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; }