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

improve serialization/deserialization struct error #21

Closed
tkruse opened this issue Aug 31, 2013 · 0 comments
Closed

improve serialization/deserialization struct error #21

tkruse opened this issue Aug 31, 2013 · 0 comments
Assignees

Comments

@tkruse
Copy link
Member

tkruse commented Aug 31, 2013

To reproduce, using two shells(e.g.):

rostopic echo /footest
rostopic pub /footest  "{x: 0.0, y: 0.0, z: 0.0.1}" 
[WARN] [WallTime: 1377942406.224566] Inbound TCP/IP connection failed: required argument is not a float

Note the topic listener is required, else no packing happens. (Sidenote: I am not sure whether this should be a warning, seems more like an error to me.)

The problem here is that the message does not contain a hint to what value was not a float. I looked at the code genpy generates for messages / service, which looks like this:

 for val1 in ...:
    _v1 = ...
    _v2 = _v1....
    _x = _v2
    buff.write(_struct...(_x....)

At least the value of _x should IMO be used in the case of errors, to indicate the writing of what failed. In my case (not using geometry_msgs/Point but a more complex message) that would have reduce me looking for the error a lot.

So a change to genpy would be to change the generated code something like this:

- except struct.error as se: self._check_types(se)
- except TypeError as te: self._check_types(te)
+ except struct.error as se: self._check_types(self._check_types(ValueError("%s: %s when writing %s" % (type(se), str(se), str(_x))))
+ except TypeError as te: self._check_types(self._check_types(ValueError("%s: %s when writing %s" % (type(te), str(te), str(_x)))))

Also see:
http://stackoverflow.com/questions/696047/re-raising-exceptions-with-a-different-type-and-message-preserving-existing-inf

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

2 participants