Improve error messages in Stream.filter and Stream.sample
authorHarmon <Harmon758@gmail.com>
Tue, 26 Jan 2021 15:22:43 +0000 (09:22 -0600)
committerHarmon <Harmon758@gmail.com>
Tue, 26 Jan 2021 15:23:06 +0000 (09:23 -0600)
tweepy/streaming.py

index 834953e2d2457dc143058903265578ca4ea93fef..ed7017640e101995cbfad85381b60f72d187d132 100644 (file)
@@ -154,7 +154,7 @@ class Stream:
                filter_level=None, languages=None, stall_warnings=False,
                threaded=False):
         if self.running:
-            raise TweepError("Stream object already connected!")
+            raise TweepError("Stream is already connected")
 
         method = "POST"
         endpoint = "statuses/filter"
@@ -167,8 +167,9 @@ class Stream:
             body["track"] = ','.join(track)
         if locations and len(locations) > 0:
             if len(locations) % 4:
-                raise TweepError("Wrong number of locations points, "
-                                 "it has to be a multiple of 4")
+                raise TweepError(
+                    "Number of location coordinates should be a multiple of 4"
+                )
             body["locations"] = ','.join(f"{l:.4f}" for l in locations)
         if filter_level:
             body["filter_level"] = filter_level
@@ -185,7 +186,7 @@ class Stream:
 
     def sample(self, *, languages=None, stall_warnings=False, threaded=False):
         if self.running:
-            raise TweepError("Stream object already connected!")
+            raise TweepError("Stream is already connected")
 
         method = "GET"
         endpoint = "statuses/sample"