Trying to make error digest less verbose

This commit is contained in:
Pavel Shevaev 2023-11-12 15:33:54 +03:00
parent 8c38d468d2
commit b7829850d6
1 changed files with 12 additions and 1 deletions

View File

@ -15,7 +15,18 @@ function _gamectl_error_handler($errno, $errstr, $errfile, $errline)
function _gamectl_exception_handler($e)
{
$msg = $e . "\n=== ERROR DIGEST ===\n" . $e->getMessage() . "\n";
$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);