docs(worker): Prefer `try-catch` over `set_exception_handler` by Slamdunk · Pull Request #1897 · php/frankenphp
I wonder if this should be in the minimal example as you did or as a note after the snippet. It definitely makes sense to mention it somewhere, just wondering if it's the right place as this snippet is about the minimal worker code to make it work.
My thought process is the chances of a project to be so advanced to leverage worker mode and still not ever set once a custom exception handler by set_exception_handler is... zero.
I got bitten very hard in production by this, and I would have loved it to be documented as a baseline
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, works for me
I suggest to reword the comment. set_exception_handler does work as expected in a worker script.
Maybe something like:
// Catch and handle the exception and handle it
I would add a note later about exception handlers, like:
> ![NOTE]
>
> Exception handlers are called only when the worker script ends, which may not be what you expect (use `try`/`catch` in this case).
WDYT?
I'm not a native english speaker, so I'm fine with any change request you are asking me, as long as the set_exception_handler word is mentioned somewhere
Slamdunk
deleted the
worker_mode_set_exception_handler
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters