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

Sphero bolt set_matrix_pixel error on bad pixel value #44

Open
Alex-x90 opened this issue Mar 7, 2024 · 2 comments
Open

Sphero bolt set_matrix_pixel error on bad pixel value #44

Alex-x90 opened this issue Mar 7, 2024 · 2 comments

Comments

@Alex-x90
Copy link

Alex-x90 commented Mar 7, 2024

I accidentally tried to use set_matrix_pixel on a negative pixel value, which crashes the program in the following way:

"spherov2\controls\v2.py", line 157, in new_packet
    packet = Packet(flags, did, cid, self.__seq, tid, sid, bytearray(data or []))
                                                           ^^^^^^^^^^^^^^^^^^^^^
ValueError: byte must be in range(0, 256)

While it makes sense that calling set_matrix_pixel on a negative pixel location wouldn't work, it should ideally be handled gracefully and at the very least return a specific error rather than crashing the program.

@superfashi
Copy link
Member

The crashing of the program is a natural result of an unhandled exception, so in this case it's better to use try...catch on the user side.

@Alex-x90
Copy link
Author

That's fine, but having a specific exception that lets you know that the issue was that the pixel coordinate was not valid (outside of the 0-7 range) rather than getting an error from an internal function with an amiguous relationship to set_matrix_pixel would be more understandable.

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