diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f80e06..dbc23dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features 1. [#237](https://github.com/influxdata/influxdb-client-python/pull/237): Use kwargs to pass query parameters into API list call - useful for the ability to use pagination. +1. [#241](https://github.com/influxdata/influxdb-client-python/pull/241): Add detail error message for not supported type of `Point.field` ## 1.17.0 [2021-04-30] diff --git a/influxdb_client/client/write/point.py b/influxdb_client/client/write/point.py index 8e5884ed..98af23ee 100644 --- a/influxdb_client/client/write/point.py +++ b/influxdb_client/client/write/point.py @@ -165,7 +165,7 @@ def _append_fields(fields): elif isinstance(value, str): _return.append(f'{_escape_key(field)}="{_escape_string(value)}"') else: - raise ValueError() + raise ValueError(f'Type: "{type(value)}" of field: "{field}" is not supported.') return f"{','.join(_return)}" diff --git a/tests/test_point.py b/tests/test_point.py index b09c231c..f37e3622 100644 --- a/tests/test_point.py +++ b/tests/test_point.py @@ -369,6 +369,16 @@ def test_points_from_different_timezones(self): point_hk = Point.measurement("h2o").field("val", 1).time(time_in_hk) self.assertEqual(point_utc.to_line_protocol(), point_hk.to_line_protocol()) + def test_unsupported_field_type(self): + with self.assertRaises(ValueError) as ve: + Point.measurement("h2o") \ + .tag("location", "europe") \ + .field("level", UTC) \ + .to_line_protocol() + exception = ve.exception + + self.assertEqual('Type: "" of field: "level" is not supported.', f'{exception}') + if __name__ == '__main__': unittest.main()