filp / whoops

PHP errors for cool kids
http://filp.github.io/whoops/
MIT License
13.2k stars 604 forks source link

PrettyPageHandler: make first frame with comments active on page load #745

Closed cogentParadigm closed 1 year ago

cogentParadigm commented 1 year ago

Hello, thank you for sharing this work!

When using the PrettyPageHandler, I would like the first frame with comments to be active when the page loads, instead of just the first frame. I would be happy to implement this myself. Would you accept a PR to apply such a change?

If not, would you accept a PR to make the active index a variable passed into the templates? This would at least make it easier to implement in a custom handler extending PrettyPageHandler.

denis-sokolov commented 1 year ago

Thank you for being very clear with your request and suggesting to do a PR. Unfortunately, in my opinion, the feature as you describe is a little too specific for the goals of Whoops.

I don’t understand your proposal to pass the active index to the templates. The active index only exists in the templates. Templates receive all frames and can render whichever index they want:

https://github.com/filp/whoops/blob/c3b67c4cb92a588e368f51b9f02b485e42b30acc/src/Whoops/Resources/views/frame_list.html.php#L4-L5

cogentParadigm commented 1 year ago

Thanks for the response. By active index, I mean the one that receives the "active" class on the frame div. It is hard coded to 0 in the template where "active" is output if $i == 0. My proposal is to change that 0 to a variable.

cogentParadigm commented 1 year ago

To add some context on the original request - the reason I want the first frame with comments to be active is that it contains the exception message. If the exception is not on the first frame, you would have to look through the frames to find it. Having it open on the frame with the exception would make this more convenient. This is also helpful if someone takes a screenshot of an error they see to get help, they will be more likely to screenshot the relevant frame.

denis-sokolov commented 1 year ago

I see. I think you should be already able to implement this with a template override. Use $handler->addResourcePath(...) to add your custom directory to the PrettyPageHandler, then copy our views/frame_list.html.php file in your custom directory, then modify it as you want!

cogentParadigm commented 1 year ago

yes, I did say in my initial request that making the active index variable would make it easier not that it was impossible, as then I wouldn't need to maintain multiple custom templates (also would need to override views/frame_code.html.php) for a relatively trivial modification. However, I guess you are not receptive to such a modification so I won't pursue it further. Thanks for getting back to me.