From 04e13afe42e120573ecbdf43a35aedaf1f1ea60b Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 22 Mar 2014 15:30:19 +0000 Subject: [PATCH] Add the Exception error management in CLI (display only the message in normal mode, and display all the trace in expert mode) git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1237 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- cli.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cli.php b/cli.php index c13d5f5..bed43d0 100644 --- a/cli.php +++ b/cli.php @@ -160,9 +160,18 @@ $cli->run(); */ } // TODO : Manage a parameter in the constructor of the class - $r = new $class; - $s = call_user_func_array(array($r, $method), $argv); - var_dump ($s); + try + { + $r = new $class; + $s = call_user_func_array(array($r, $method), $argv); + var_dump ($s); + } + catch (Exception $e) + { + file_put_contents("php://stderr", $e->getMessage()."\n"); + if ($EXPERT) + file_put_contents ("php://stderr", $e->getTraceAsString()."\n"); + } exit; } }