summaryrefslogtreecommitdiffhomepage
path: root/libs/simple_websocket/errors.py
blob: 535b9d661a982b00b63e5e5e708db40188a897f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from wsproto.frame_protocol import CloseReason


class ConnectionError(RuntimeError):  # pragma: no cover
    """Connection error exception class."""
    def __init__(self, status_code=None):
        self.status_code = status_code
        super().__init__(f'Connection error: {status_code}')


class ConnectionClosed(RuntimeError):
    """Connection closed exception class."""
    def __init__(self, reason=CloseReason.NO_STATUS_RCVD, message=None):
        self.reason = reason
        self.message = message
        super().__init__(f'Connection closed: {reason} {message or ""}')