msgpack-php
msgpack-php copied to clipboard
Throw exceptions when not possible to unpack
We're attempting to include MsgPack as one possible serializer for our suite but we found the problem that when it is not possible to unpack data, msgpack_unpack triggers an error.
This is a big problem because in PHP it is not possible to capture a PHP error and act accordingly, so I propose two solutions:
- Create a MessagePackException that is thrown whenever an error occurs. This can be easily try/catch'ed in a controlled way. This would be great por the OO API (MsgPack class).
- Return a specific value when a problem occurs (false, for example) and add a msgpack_last_error() function that returns information about how it was the last unpack operation. This is the behaviour used by the JSON lib on PHP. http://www.php.net//manual/en/function.json-last-error.php
That would be great! :+1:
:+1: