X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fplatal.inc.php;h=f9bf12717e1e1486917d88c4e9dd13b6e831cab7;hb=13cec5adcabc015959a87a75ef67cc354242a6bd;hp=38912a22dc2b23bf6d48b74baeb070f205525a6b;hpb=983284ba502852d0d50c9073274d6de3001acab6;p=platal.git
diff --git a/include/platal.inc.php b/include/platal.inc.php
index 38912a2..f9bf127 100644
--- a/include/platal.inc.php
+++ b/include/platal.inc.php
@@ -1,6 +1,6 @@
".
- "{$type} $errstr
".
- "$errfile : $errline".
- "";
- }
-}
+ $error = strpos($type, 'Warning') !== false || strpos($type, 'Error') !==false;
-function pl_clear_errors()
-{
- unset($GLOBALS['pl_errors']);
+ if (!isset(PlBacktrace::$bt['PHP Errors'])) {
+ new PlBacktrace('PHP Errors');
+ }
+ PlBacktrace::$bt['PHP Errors']->newEvent("$type: $errstr",
+ 0, $error ? $errstr : null,
+ array(array('file' => $errfile,
+ 'line' => $errline)));
}
function pl_dump_env()
@@ -117,15 +127,34 @@ function pl_dump_env()
echo "";
}
-function pl_print_errors()
+function pl_print_errors($html = false)
{
- if (!empty($GLOBALS['pl_errors'])) {
- print join("\n", $GLOBALS['pl_errors']);
+ if (!isset(PlBacktrace::$bt['PHP Errors'])) {
+ return;
+ }
+ foreach (PlBacktrace::$bt['PHP Errors']->traces as $trace) {
+ if ($html) {
+ echo "
"; + } + print "{$trace['action']}\n"; + print " {$trace['data'][0]['file']}: {$trace['data'][0]['line']}\n"; + if ($html) { + echo ""; + } } } +function pl_assert_cb($file, $line, $message) +{ + Platal::assert(false, "Assertion failed at $file:$line with message: $message"); +} + set_error_handler('pl_error_handler', E_ALL | E_STRICT); -register_shutdown_function('pl_print_errors'); +assert_options(ASSERT_CALLBACK, 'pl_assert_cb'); +assert_options(ASSERT_WARNING, false); +if (php_sapi_name() == 'cli') { + register_shutdown_function('pl_print_errors'); +} //register_shutdown_function('pl_dump_env'); /** Check if the string is utf8