3

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

2 Answers 2

6

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>'; 
Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

I was looking at that but that call doesn't give me the information from the exception. I'm capturing unhandled Exception and I want to get the stack at the time of the exception.
Keep in mind that options for xdebug_print_function_stack() are only available since Xdebug 2.3. (is that version even released?) xdebug.org/docs/stack_trace#xdebug_print_function_stack

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.