Skip to content

Exceptions

⚠️ Exceptions

Exception classes for error handling.

⚠️ Exception Classes

NetworkHD API client exceptions.

This module defines custom exception classes for the NetworkHD API client. These exceptions provide detailed error information and help with debugging.

ConnectionError and TimeoutError shadow the builtins of the same name but also subclass them, so except builtins.ConnectionError / except builtins.TimeoutError still catch them.

NetworkHDError

Bases: Exception

Base exception for NetworkHD API errors

ConnectionError

Bases: NetworkHDError, ConnectionError

Exception raised when connection fails or the client is not connected

ConnectionLostError

ConnectionLostError(host: str, reason: str | None = None)

Bases: ConnectionError

Exception raised when connection is unexpectedly lost

ReconnectionError

ReconnectionError(host: str, attempts: int, last_error: str)

Bases: ConnectionError

Exception raised when reconnection attempts fail

HostKeyMismatchError

HostKeyMismatchError(host: str, presented_fingerprint: str)

Bases: ConnectionError

Exception raised when the SSH server's host key matches none of the pinned fingerprints.

Raised before authentication, so the password is never sent to that server.

AuthenticationError

AuthenticationError(username: str, host: str)

Bases: NetworkHDError

Exception raised when authentication fails

TimeoutError

TimeoutError(operation: str, timeout: float)

Bases: NetworkHDError, TimeoutError

Exception raised when operations timeout, e.g. no response to a command

CommandError

Bases: NetworkHDError

Exception raised when command execution fails

ResponseError

Bases: NetworkHDError, ValueError

Exception raised when response parsing fails

UnknownCommandError

UnknownCommandError(command: str)

Bases: CommandError

Exception raised when the device answers "unknown command" (unknown command or incorrect parameters)

DeviceNotFoundError

DeviceNotFoundError(device_name: str)

Bases: NetworkHDError

Exception raised when a device does not exist

DeviceQueryError

DeviceQueryError(device_name: str, error_message: str)

Bases: NetworkHDError

Exception raised when device query returns error in JSON response