Skip to content

Commit

Permalink
Add a top-level exception class
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Oct 10, 2024
1 parent d4f05c7 commit 0dcf341
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/simple_websocket/errors.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from wsproto.frame_protocol import CloseReason


class ConnectionError(RuntimeError): # pragma: no cover
class SimpleWebsocketError(RuntimeError):
pass


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


class ConnectionClosed(RuntimeError):
class ConnectionClosed(SimpleWebsocketError):
"""Connection closed exception class."""
def __init__(self, reason=CloseReason.NO_STATUS_RCVD, message=None):
self.reason = reason
Expand Down

0 comments on commit 0dcf341

Please sign in to comment.