Exceptions¶
All exceptions inherit from IcomLanError for easy catch-all handling.
Hierarchy¶
IcomLanError
├── ConnectionError
├── AuthenticationError
├── CommandError
├── TimeoutError
└── AudioError
├── AudioCodecBackendError
├── AudioFormatError
└── AudioTranscodeError
Classes¶
IcomLanError¶
Base exception for all icom-lan errors. Catch this to handle any library error.
try:
async with IcomRadio(...) as radio:
...
except IcomLanError as e:
print(f"icom-lan error: {e}")
ConnectionError¶
Raised when a connection to the radio fails or is lost.
- UDP socket creation failed
- Network unreachable
- Radio dropped the connection
Note
This is icom_lan.ConnectionError, not the built-in builtins.ConnectionError. Import explicitly to avoid shadowing.
AuthenticationError¶
Raised when authentication with the radio fails.
- Wrong username or password
- Account disabled
- Too many concurrent connections
CommandError¶
Raised when a CI-V command is rejected by the radio (NAK response).
- Frequency out of range
- Invalid mode for current state
- Feature not supported by radio model
TimeoutError¶
Raised when an operation doesn't complete within the timeout period.
- Discovery timed out (radio not found)
- CI-V command response not received
- Status packet not received during handshake
Note
This is icom_lan.TimeoutError, not the built-in builtins.TimeoutError. Import explicitly to avoid shadowing.
AudioError¶
Base class for audio codec/transcoding failures.
AudioCodecBackendError¶
Raised when no Opus backend is available for PCM/Opus conversion.
opuslibnot installed- backend failed initialization
Typical actionable message:
Audio codec backend unavailable; install icom-lan[audio].
AudioFormatError¶
Raised when provided audio frame format is invalid.
- Unsupported sample rate/channel/frame duration
- Wrong PCM frame byte length
- Empty/invalid Opus frame input
AudioTranscodeError¶
Raised when encode/decode fails in the codec backend.
Usage Patterns¶
Catch specific errors¶
from icom_lan import IcomRadio
from icom_lan.exceptions import (
ConnectionError,
AuthenticationError,
CommandError,
TimeoutError,
)
try:
async with IcomRadio("192.168.1.100", username="u", password="p") as radio:
await radio.set_frequency(999_999_999)
except ConnectionError:
print("Cannot reach the radio")
except AuthenticationError:
print("Check your credentials")
except CommandError:
print("Radio rejected the command")
except TimeoutError:
print("Radio not responding")