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:
19
cli.php
19
cli.php
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user