Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw exceptions when not possible to unpack #32

Open
adanlobato opened this issue Jun 26, 2014 · 2 comments
Open

Throw exceptions when not possible to unpack #32

adanlobato opened this issue Jun 26, 2014 · 2 comments

Comments

@adanlobato
Copy link

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
@ghost
Copy link

ghost commented Jun 30, 2014

That would be great! 👍

@rybakit
Copy link
Contributor

rybakit commented May 7, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants