Skip to content

Commit 3c73ca2

Browse files
committed
Add connection exceptions specific to streaming.
1 parent 907bf41 commit 3c73ca2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plotly/exceptions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,20 @@ class PlotlyAccountError(PlotlyServerError):
234234

235235
class PlotlyRateLimitError(PlotlyServerError):
236236
pass
237+
238+
239+
class ClosedConnection(PlotlyConnectionError):
240+
"""Raised when the Plotly streaming server has disconnected."""
241+
def __init__(self, message, status_code=None):
242+
self.message = "[Code: {}] {}".format(status_code, message)
243+
self.status_code = status_code or None
244+
super(ClosedConnection, self).__init__(self.message)
245+
246+
247+
class TooManyConnectFailures(PlotlyConnectionError):
248+
"""Raised when too many unsuccessful (re)connects were attempted"""
249+
message = "Connecting or reconnecting to stream failed too many times."
250+
251+
def __init__(self, message=None):
252+
message = message or self.message
253+
super(TooManyConnectFailures, self).__init__(message)

0 commit comments

Comments
 (0)