-
Notifications
You must be signed in to change notification settings - Fork 0
Exceptions
vihaanvp edited this page Jun 25, 2026
·
1 revision
Exception
└── MegaWrapperError # Base for all library errors
├── InvalidSpeedError # Speed not a number or outside 0-100
├── BoardConnectionError # Cannot connect to Arduino
└── StandbyNotConfiguredError # wake()/sleep() called without STBY pin
Additionally, the library may raise standard Python exceptions:
| Exception | Raised by | Condition |
|---|---|---|
RuntimeError |
Servo.attach() |
No Board has been created yet. |
RuntimeError |
Servo.write/read/... |
Servo not attached via attach(). |
RuntimeError |
Servo.read() |
write() never called — angle unknown. |
ValueError |
Servo.sweep() |
step <= 0. |
ValueError |
Servo.write() |
Angle is not a number. |
from megawrapper import MegaWrapperError
try:
board = Board("COM3")
motor = board.attach_motor(2, 4, 11)
motor.forward(999) # raises InvalidSpeedError
except MegaWrapperError as e:
print(f"MegaWrapper error: {e}")