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

MsgPack::pack() and unpack() can not report pack/unpack error. #31

Closed
hgoldfish opened this issue Jun 18, 2018 · 2 comments
Closed

MsgPack::pack() and unpack() can not report pack/unpack error. #31

hgoldfish opened this issue Jun 18, 2018 · 2 comments

Comments

@hgoldfish
Copy link

if QVariantList contains some element that can not be packed, the packer just silently ignore this element and print warning, There is no way to report this error to upper caller.

QVariantList l;
l << 1 << 2 << objectCanNotPacked() << 3;
qDebug() << MsgPack::unpack(MsgPack::pack(l));

Then 1,2,3, is output.

@hgoldfish hgoldfish changed the title MsgPack::pack() and unpack() can report pack/unpack error. MsgPack::pack() and unpack() can not report pack/unpack error. Jun 18, 2018
@romixlab
Copy link
Owner

Sorry for late answer.
Precisely in this case I don't see any other choice than to throw an exception, but that would kill whole process if not caught...
Maybe add MsgPack::strictMode(true) which would enable exceptions in such cases, what do you think?

@hgoldfish
Copy link
Author

I think, the MsgpackStream should be used to replace the MsgPack::pack() and MsgPack::unpack() using these operators:

MsgpackStream &MsgpackStream::operator<<(const QVariant &v);
MsgpackStream &MsgpackStream::operator>>(QVariant &v);

At the meantime, MsgpackStream can report errors via status() during serialization.

I implements a simple version based on your codes:

https://github.com/hgoldfish/qtnetworkng/blob/master/include/msgpack.h
https://github.com/hgoldfish/qtnetworkng/blob/master/src/msgpack.cpp

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

No branches or pull requests

2 participants