KMK-ONLINE / xhp-php7-extension

A PHP7 extension that augments the syntax of the language such that XML document fragments become valid PHP expressions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing stack trace

firodj opened this issue · comments

whenever there are an erroe like E_COMPILE_ERROR on child class, just like misuse use statement, the stack trace doesnt point the original nor correct file.

this is depend on how the toString() method handle the exception since toString must not throw an Exception.

} catch (Exception $error) {
-      trigger_error($error->getMessage(), E_USER_ERROR);
+      $previousHandler = set_exception_handler(function () {});
+      restore_error_handler();
+      if (! $previousHandler) {
+          $str = $error->getMessage()."\n";
+          $str .= $error->getTraceAsString();
+          return $str;
+      } else {
+          call_user_func($previousHandler, $error);
+      }
+      die;
     }