Add error management in CLI (display the trigger_errors in stderr)

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1732 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-08-19 09:05:55 +00:00
parent 9eb50a537e
commit 8056491a1a

19
cli.php
View File

@@ -13,6 +13,25 @@ class cli
require ("domframework/cli.php"); require ("domframework/cli.php");
$cli = new cli; $cli = new cli;
$cli->run(); */ $cli->run(); */
public function __construct ()
{
// Catch the trigger_errors and display them politely
set_error_handler(array(&$this, "cliErrorHandler"));
}
/** The error handler for CLI : display error in STDERR */
public function cliErrorHandler ($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno))
{
// This error code is not included in error_reporting
return;
}
file_put_contents ("php://stderr", "$errstr [".basename ($errfile) .
":$errline]\n");
}
public function run () public function run ()
{ {
global $argv; global $argv;