Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e09dde

Browse filesBrowse files
authored
fix: construct InfluxDBError without http response (influxdata#375)
1 parent cb23528 commit 7e09dde
Copy full SHA for 7e09dde

File tree

3 files changed

+19
-4
lines changed
Filter options

3 files changed

+19
-4
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
## 1.25.0 [unreleased]
22

3+
### Bug Fixes
4+
1. [#375](https://github.com/influxdata/influxdb-client-python/pull/375): Construct `InfluxDBError` without HTTP response
5+
36
### CI
4-
1. [#54](https://github.com/influxdata/influxdb-client-python/pull/370): Add Python 3.10 to CI builds
7+
1. [#370](https://github.com/influxdata/influxdb-client-python/pull/370): Add Python 3.10 to CI builds
8+
59
## 1.24.0 [2021-11-26]
610

711
### Features

‎influxdb_client/client/exceptions.py

Copy file name to clipboardExpand all lines: influxdb_client/client/exceptions.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ class InfluxDBError(Exception):
1212

1313
def __init__(self, response: HTTPResponse):
1414
"""Initialize the InfluxDBError handler."""
15-
self.response = response
16-
self.message = self._get_message(response)
17-
self.retry_after = response.getheader('Retry-After')
15+
if response is not None:
16+
self.response = response
17+
self.message = self._get_message(response)
18+
self.retry_after = response.getheader('Retry-After')
19+
else:
20+
self.response = None
21+
self.message = 'no response'
22+
self.retry_after = None
1823
super().__init__(self.message)
1924

2025
def _get_message(self, response):

‎tests/test_InfluxDBError.py

Copy file name to clipboardExpand all lines: tests/test_InfluxDBError.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ def test_message_get_retry_after(self):
4646
influx_db_error = InfluxDBError(response=HTTPResponse(reason="too many requests"))
4747
self.assertEqual("too many requests", str(influx_db_error))
4848
self.assertEqual(None, influx_db_error.retry_after)
49+
50+
def test_no_response(self):
51+
influx_db_error = InfluxDBError(response=None)
52+
self.assertEqual("no response", str(influx_db_error))
53+
self.assertIsNone(influx_db_error.response)
54+
self.assertIsNone(influx_db_error.retry_after)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.