File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ def send_request(
8080 raise MeilisearchTimeoutError (str (err )) from err
8181 except requests .exceptions .ConnectionError as err :
8282 raise MeilisearchCommunicationError (str (err )) from err
83+ except requests .exceptions .InvalidSchema as err :
84+ if "://" not in self .config .url :
85+ raise MeilisearchCommunicationError (
86+ f"""
87+ Invalid URL { self .config .url } , no scheme/protocol supplied.
88+ Did you mean https://{ self .config .url } ?
89+ """
90+ ) from err
91+
92+ raise MeilisearchCommunicationError (str (err )) from err
8393
8494 def get (self , path : str ) -> Any :
8595 return self .send_request (requests .get , path )
Original file line number Diff line number Diff line change @@ -17,3 +17,12 @@ def test_meilisearch_communication_error_host(mock_post):
1717 client = meilisearch .Client ("http://wrongurl:1234" , MASTER_KEY )
1818 with pytest .raises (MeilisearchCommunicationError ):
1919 client .create_index ("some_index" )
20+
21+
22+ @patch ("requests.post" )
23+ def test_meilisearch_communication_error_no_protocol (mock_post ):
24+ mock_post .configure_mock (__name__ = "post" )
25+ mock_post .side_effect = requests .exceptions .InvalidSchema ()
26+ client = meilisearch .Client ("localhost:7700" , MASTER_KEY )
27+ with pytest .raises (MeilisearchCommunicationError , match = "no scheme/protocol supplied." ):
28+ client .create_index ("some_index" )
You can’t perform that action at this time.
0 commit comments