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

mavutil: Raise ValueError instead of exiting #931

Merged
merged 1 commit into from
Mar 21, 2024
Merged

mavutil: Raise ValueError instead of exiting #931

merged 1 commit into from
Mar 21, 2024

Conversation

Newbytee
Copy link
Contributor

Users of this library may want to handle these values being wrong. While it is possible to handle sys.exit, it is more conventional to raise a ValueError on incorrect data passed as an argument.

Users of this library may want to handle these values being wrong. While
it is possible to handle sys.exit, it is more conventional to raise a
ValueError on incorrect data passed as an argument.
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested MAVProxy's error output and it doesn't make much difference as MAVProxy caches any exception and handles it:

pbarker@fx:~/rc/pymavlink((HEAD detached at Newbytee/raise-value-error-instead-of-exit))$ mavproxy.py --master udp:bob
Connect udp:bob source_system=255
Failed to connect to udp:bob : UDP ports must be specified as host:port
pbarker@fx:~/rc/pymavlink((HEAD detached at Newbytee/raise-value-error-instead-of-exit))$ 

... it actually fixes a bug in MAVProxy if you screw up:

STABILIZE> Adding link udp:bob
Connect udp:bob source_system=255
UDP ports must be specified as host:port

STABILIZE> 
STABILIZE> 
STABILIZE> link add udp:bob
STABILIZE> 
STABILIZE> 
STABILIZE> 
STABILIZE> link add udp:bob
STABILIZE> status
STABILIZE> status
STABILIZE> 

@peterbarker peterbarker merged commit a71c7b7 into ArduPilot:master Mar 21, 2024
12 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@Newbytee Newbytee deleted the raise-value-error-instead-of-exit branch March 21, 2024 16:15
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

Successfully merging this pull request may close these issues.

2 participants