39 lines
903 B
PHP
39 lines
903 B
PHP
<?php
|
|
|
|
function _gamectl_error_handler($errno, $errstr, $errfile, $errline)
|
|
{
|
|
if($errno == E_STRICT)
|
|
return;
|
|
|
|
// @ sign temporary disabled error reporting
|
|
if(error_reporting() == 0)
|
|
return;
|
|
|
|
$err = "Error happened: $errno, $errstr, $errfile, $errline\n";
|
|
throw new Exception($err);
|
|
}
|
|
|
|
function _gamectl_exception_handler($e)
|
|
{
|
|
$lines = preg_split("/\r\n|\n|\r/", $e->getMessage());
|
|
$digest = '';
|
|
//let's filter out too stack traces which are printed anyway
|
|
foreach($lines as $idx => $line)
|
|
{
|
|
if($idx > 0 && preg_match('~^#\d+\s+~', $line))
|
|
break;
|
|
$digest .= $line . "\n";
|
|
}
|
|
$digest = trim($digest);
|
|
|
|
$msg = $e . "\n=== ERROR DIGEST ===\n" . $digest . "\n";
|
|
$stderr = fopen('php://stderr', 'a');
|
|
fwrite($stderr, $msg);
|
|
fclose($stderr);
|
|
exit(1);
|
|
}
|
|
|
|
set_error_handler("_gamectl_error_handler");
|
|
set_exception_handler("_gamectl_exception_handler");
|
|
|