Errors
Errors
These are the exceptions raised by the SDK. MeilisearchApiError is raised when Meilisearch
returns an error response, and MeilisearchCommunicationError is raised when Meilisearch cannot
be reached at all.
Errors API
meilisearch_python_sdk.errors
BatchNotFoundError
Bases: Exception
Source code in meilisearch_python_sdk/errors.py
| class BatchNotFoundError(Exception):
pass
|
InvalidDocumentError
Bases: Exception
Error for documents that are not in a valid format for Meilisearch.
Source code in meilisearch_python_sdk/errors.py
| class InvalidDocumentError(Exception):
"""Error for documents that are not in a valid format for Meilisearch."""
pass
|
MeilisearchError
Bases: Exception
Generic class for Meilisearch error handling.
Source code in meilisearch_python_sdk/errors.py
| class MeilisearchError(Exception):
"""Generic class for Meilisearch error handling."""
def __init__(self, message: str) -> None:
self.message = message
super().__init__(self.message)
def __str__(self) -> str:
return f"MeilisearchError. Error message: {self.message}."
|
message
instance-attribute
__init__
__init__(message: str) -> None
Source code in meilisearch_python_sdk/errors.py
| def __init__(self, message: str) -> None:
self.message = message
super().__init__(self.message)
|
__str__
Source code in meilisearch_python_sdk/errors.py
| def __str__(self) -> str:
return f"MeilisearchError. Error message: {self.message}."
|
MeilisearchApiError
Bases: MeilisearchError
Error sent by Meilisearch API.
Source code in meilisearch_python_sdk/errors.py
| class MeilisearchApiError(MeilisearchError):
"""Error sent by Meilisearch API."""
def __init__(self, error: str, response: Response) -> None:
self.status_code = response.status_code
self.code = ""
self.message = ""
self.link = ""
self.error_type = ""
error_json = None
if response.content:
try:
error_json = response.json()
except json.JSONDecodeError:
error_json = None
if isinstance(error_json, dict):
self.message = f"Error message: {error_json.get('message') or ''}"
self.code = f"{error_json.get('code') or ''}"
self.error_type = f"{error_json.get('type') or ''}"
self.link = f"Error documentation: {error_json.get('link') or ''}"
else:
self.message = error
super().__init__(self.message)
def __str__(self) -> str:
return f"MeilisearchApiError.{self.code} {self.message} {self.error_type} {self.link}"
|
status_code
instance-attribute
status_code = response.status_code
message
instance-attribute
error_type
instance-attribute
__init__
__init__(error: str, response: Response) -> None
Source code in meilisearch_python_sdk/errors.py
| def __init__(self, error: str, response: Response) -> None:
self.status_code = response.status_code
self.code = ""
self.message = ""
self.link = ""
self.error_type = ""
error_json = None
if response.content:
try:
error_json = response.json()
except json.JSONDecodeError:
error_json = None
if isinstance(error_json, dict):
self.message = f"Error message: {error_json.get('message') or ''}"
self.code = f"{error_json.get('code') or ''}"
self.error_type = f"{error_json.get('type') or ''}"
self.link = f"Error documentation: {error_json.get('link') or ''}"
else:
self.message = error
super().__init__(self.message)
|
__str__
Source code in meilisearch_python_sdk/errors.py
| def __str__(self) -> str:
return f"MeilisearchApiError.{self.code} {self.message} {self.error_type} {self.link}"
|
MeilisearchCommunicationError
Bases: MeilisearchError
Error when connecting to Meilisearch.
Source code in meilisearch_python_sdk/errors.py
| class MeilisearchCommunicationError(MeilisearchError):
"""Error when connecting to Meilisearch."""
def __str__(self) -> str:
return f"MeilisearchCommunicationError, {self.message}"
|
__str__
Source code in meilisearch_python_sdk/errors.py
| def __str__(self) -> str:
return f"MeilisearchCommunicationError, {self.message}"
|
MeilisearchTaskFailedError
Bases: MeilisearchError
Error when a task is in the failed status.
Source code in meilisearch_python_sdk/errors.py
| class MeilisearchTaskFailedError(MeilisearchError):
"""Error when a task is in the failed status."""
def __str__(self) -> str:
return f"MeilisearchTaskFailedError, {self.message}"
|
__str__
Source code in meilisearch_python_sdk/errors.py
| def __str__(self) -> str:
return f"MeilisearchTaskFailedError, {self.message}"
|
MeilisearchTimeoutError
Bases: MeilisearchError
Error when Meilisearch operation takes longer than expected.
Source code in meilisearch_python_sdk/errors.py
| class MeilisearchTimeoutError(MeilisearchError):
"""Error when Meilisearch operation takes longer than expected."""
def __str__(self) -> str:
return f"MeilisearchTimeoutError, {self.message}"
|
__str__
Source code in meilisearch_python_sdk/errors.py
| def __str__(self) -> str:
return f"MeilisearchTimeoutError, {self.message}"
|