From b7829850d6ecbafdb4aedc57c7cf0a40e61c1ff8 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Sun, 12 Nov 2023 15:33:54 +0300 Subject: [PATCH] Trying to make error digest less verbose --- error.inc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/error.inc.php b/error.inc.php index 9411236..3577611 100644 --- a/error.inc.php +++ b/error.inc.php @@ -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);