I just thought debugging nested try-catch blocks can be pretty difficult especially if they are spread around in a framework as well as in your own code.
I don't want to talk about the fact if this is actually a good software pattern or not, just the fact that it sometimes is unavoidable and therefore people have to deal with it.
So is there maybe currently a way how to debug that in Xdebug?
If not - could this be a useful feature which Xdebug could maybe support?
My Answer:
Currently, Xdebug does not have a built-in feature to show currently active try-catch blocks. However, you can use the xdebug_get_function_stack() function to get a stack trace of the currently executing code, which can help you identify which try-catch blocks are currently active.
Alternatively, you can use a debugger like PhpStorm or Visual Studio Code with Xdebug integration, which may provide more advanced debugging features to help you navigate through nested try-catch blocks.
Adding a feature to Xdebug to specifically show currently active try-catch blocks could be a useful enhancement for developers dealing with complex nested try-catch structures. You may consider submitting a feature request to the Xdebug project on their GitHub repository to suggest this idea for consideration in future updates.
Rate this post
3 of 5 based on 8922 votesComments