| 1 |
"""Provide exceptions for aiovlc.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
|
| 6 |
class AIOVLCError(Exception): |
| 7 |
"""Represent a common error for aiovlc.""" |
| 8 |
|
| 9 |
|
| 10 |
class ConnectError(AIOVLCError): |
| 11 |
"""Represent a connection error for aiovlc.""" |
| 12 |
|
| 13 |
|
| 14 |
class ConnectReadError(ConnectError): |
| 15 |
"""The client failed to read.""" |
| 16 |
|
| 17 |
def __init__(self, error: Exception, partial_bytes: bytes | None = None) -> None: |
| 18 |
"""Set up error.""" |
| 19 |
message = f"Failed to read: {error}." |
| 20 |
|
| 21 |
if partial_bytes is not None: |
| 22 |
message = f"{message} Partial bytes read: {partial_bytes!r}" |
| 23 |
|
| 24 |
super().__init__(message) |
| 25 |
self.partial_bytes = partial_bytes |
| 26 |
|
| 27 |
|
| 28 |
class AuthError(AIOVLCError): |
| 29 |
"""Represent an authentication error.""" |
| 30 |
|
| 31 |
|
| 32 |
class CommandError(AIOVLCError): |
| 33 |
"""Represent a command error.""" |
| 34 |
|
| 35 |
|
| 36 |
class CommandParameterError(CommandError): |
| 37 |
"""Represent an error with a parameter when calling the command.""" |
| 38 |
|
| 39 |
|
| 40 |
class CommandParseError(CommandError): |
| 41 |
"""Represent an error when parsing the command output.""" |