Search code examples
phperror-handlingstack-tracewhoops

Add arguments to Whoops stack frames


This might be a stupid question but I can't really see it in the documentation: is there a config variable (ideally) or an unobtrusive way to add a callback into Whoops (specifically the PrettyPageHandler) so that each frame has its arguments in the info detail area on the right? I'd rather not have to basically copy-and-edit PrettyPageHandler just to get it in because I don't want to have issues if I update my version of Whoops in the future.

I've looked into adding a handler to the stack to modify each frame by adding its arguments as a frame comment but ran into problems immediately. Either one of the following is happening:

  1. Whoops's PrettyPageHandler doesn't show frame comments. Assuming my handler is correctly adding some text to the comment section (I've tried it with just a string rather than trying to get the args list) when I place the handler before the PrettyPageHandler in the stack, then PrettyPageHandler isn't showing the comments.

    or

  2. Whoops can't handle multiple handlers actually doing anything:

    • If I add my handler first, nothing appears to be different (see point 1 above, though)
    • If I add it last I get no Whoops output at all

From the documentation it looks like there's a way to get the arguments from a given frame (see Frame::getArgs()), but it would appear that as yet Whoops does not have this implemented in its default handler, or at least not that I can see.

Am I right in that this is pretty much not currently possible without making a whole PrettyPageHandler of my own or am I missing something pretty obvious?


Solution

  • Seems that basically this is currently not possible with a stable version of Whoops, but it is available in a feature branch (in unstable state) and planned for later version (possibly as default behaviour, too).

    Source:

    https://github.com/filp/whoops/issues/15