Methods for an Xdebug Exception class

青春壹個敷衍的年華 提交于 2019-12-02 06:34:14

问题


Is it possible to see the methods of the extended Exception class Xdebug creates? I want to get at the HTML formatted stack trace.


回答1:


So after hacking at it, there's no method like Niels showed but there's a public property called $exception->xdebug_message that has the HTML formatted message. Don't forget to wrap it in a table tag if you are placing it in a HTML page.

echo '<table>';
echo $exception->xdebug_message;
echo '</table>';



回答2:


To get the fancy HTML outputted trace:

ob_start();
xdebug_print_function_stack();
$myFancyHTMLOutput = ob_get_clean();

Pass the option XDEBUG_STACK_NO_DESC to leave out the header.

However, Xdebug does not actually patch visible methods into Exception, as evidenced by printing get_class_methods($e) inside an exception handler:

array (size=9)
  0 => string '__construct' (length=11)
  1 => string 'getMessage' (length=10)
  2 => string 'getCode' (length=7)
  3 => string 'getFile' (length=7)
  4 => string 'getLine' (length=7)
  5 => string 'getTrace' (length=8)
  6 => string 'getPrevious' (length=11)
  7 => string 'getTraceAsString' (length=16)
  8 => string '__toString' (length=10)

You can of course always format it yourself from the array returned by getTrace, but that has nothing to do with Xdebug and is just built in functionality.



来源:https://stackoverflow.com/questions/24740240/methods-for-an-xdebug-exception-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!