Re: [VOTE] Improve unserialize() error handling

From: Date: Tue, 18 Oct 2022 11:32:32 +0000
Subject: Re: [VOTE] Improve unserialize() error handling
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-118839@lists.php.net to get a copy of this message
Hi On 10/18/22 09:32, Derick Rethans wrote:
If I'm reading the implementation correctly, the original exception is thrown away, there's no way to get the original message and backtrace. That will make debugging more difficult.
I believe that is not true. It should be wrapped and accessible through ->previous on the exception.
Correct, the original Exception/Error will be available using $e->getPrevious(). This is also explained in the RFC in the "Add wrapper Exception 'UnserializationFailedException'" section:
The original \Throwable will be accessible through the $previous property of \UnserializationFailedException, allowing the developer to learn about the actual cause of the unserialization failure by inspecting ->getPrevious().
This is not apparent from taking a cursory look at the diff of the native implementation in the pull request, because setting $previous will happen implicitly whenever native code throws an Exception, while an Exception is already "active". Best regards Tim Düsterhus

« previous php.internals (#118839) next »