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

Why TypeError is not subclass of UnpackError? #83

Closed
funny-falcon opened this issue Aug 2, 2015 · 1 comment
Closed

Why TypeError is not subclass of UnpackError? #83

funny-falcon opened this issue Aug 2, 2015 · 1 comment

Comments

@funny-falcon
Copy link
Contributor

It is strange, that MessagePack::TypeError is a separate species. Why it is not sublclass of UnpackError?

@frsyuki
Copy link
Member

frsyuki commented Aug 3, 2015

That "was" because of a plan to implement data type conversion module like msgpack-java's Template or jackson-dataformat-msgpack. MessageTypeException defined there can be thrown from "data type conversion module" which is not unpacker.
But it sounds confusing in msgpack-ruby. I created #85 to focus on this issue.

@frsyuki frsyuki closed this as completed Aug 3, 2015
frsyuki added a commit that referenced this issue Aug 3, 2015
This change adds MessagePack::UnexpectedTypeError which extends
UnpackError. Unpacker raises it instead of TypeError.

This doesn't take alternative idea which changes TypeError to
extends UnpackError for 2 reasons:

* For backward compatibility with existent code which expects that
  rescuing TypeError doesn't rescue UnpackError.
* Name of "TypeError" is confusing with Ruby's standard "::TypeError".

For backward compatibility, TypeError is changed to Module and
UnexpectedTypeError includes it.
frsyuki added a commit that referenced this issue Aug 5, 2015
This change adds MessagePack::UnexpectedTypeError which extends
UnpackError. Unpacker raises it instead of TypeError.

This doesn't take alternative idea which changes TypeError to
extends UnpackError for 2 reasons:

* For backward compatibility with existent code which expects that
  rescuing TypeError doesn't rescue UnpackError.
* Name of "TypeError" is confusing with Ruby's standard "::TypeError".

For backward compatibility, TypeError is changed to Module and
UnexpectedTypeError includes it.
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