On Tue, Nov 18, 2025 at 7:38 PM Jakub Zelenka <[email protected]> wrote:
> Hello, > > I would like to introduce a new stream error handling RFC that is part of > my stream evolution work (PHP Foundation project funded by Sovereign Tech > Fund) : > > https://wiki.php.net/rfc/stream_errors > > Hi, I just published version 2.0 which is a significant redesign including: - Introducing StreamErrorStore, StreamErrorMode and StreamErrorCode enums (the code also includes various suggested helper methods). The code is backed (int) because I need to keep the number to easily match the category and simplify the mapping. I think that in this case a backed enum is better. - The error data are now in a StreamError class instead of an associative array. This also simplifies StreamException which now has just a single method to return the StreamError instance. The error handler callback signature was also simplified to take just a single StreamError parameter instead of multiple individual parameters. - Errors are now grouped per operation and reported at the end of the call. This also supports nested calls (e.g. in user streams) so they don't overlap. And it delays the execution of error handlers (not just the stream error callback but also the usual error handler if default standard error triggering is used) which should be safer as noted by Arnaud. - The storing of errors is done at the end of the operation grouping and contains only the last grouped errors. So the function name was changed to stream_get_last_error(). It returns just a single StreamError which has a next property pointing to the next error if there is any. - Stream is no longer exposed and errors are not collected on streams but globally in the same way as wrappers. It is actually no longer even collected per wrapper because it doesn't make much sense when the errors are grouped per operation. - Terminal (and NonTerminal) was renamed to Terminating (and NonTerminating). - Invalid enum types for context options (error_mode and error_store) now throw TypeError. - Implemented operation pooling to minimize memory allocations during error handling (pre-allocated pool for up to 8 nested operations). I hope this addresses all concerns. Kind regards, Jakub
