Skip to content

Commit 970da7a

Browse files
bors[bot]Volodymyr Yevtushenkoalallema
authored
Merge #388
388: Add type attribute to error handler r=alallema a=voloyev ## What does this PR do? Fixes #354 ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to MeiliSearch! Co-authored-by: Volodymyr Yevtushenko <[email protected]> Co-authored-by: Amélie <[email protected]>
2 parents f63ff55 + 28f0729 commit 970da7a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

meilisearch/errors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ def __init__(self, error: str, request: Response) -> None:
1919
self.status_code = request.status_code
2020
self.code = None
2121
self.link = None
22+
self.type = None
2223

2324
if request.text:
2425
json_data = json.loads(request.text)
2526
self.message = json_data.get('message')
2627
self.code = json_data.get('code')
2728
self.link = json_data.get('link')
29+
self.type = json_data.get('type')
2830
else:
2931
self.message = error
3032
super().__init__(self.message)
3133

3234
def __str__(self) -> str:
3335
if self.code and self.link:
34-
return f'MeiliSearchApiError. Error code: {self.code}. Error message: {self.message} Error documentation: {self.link}'
36+
return f'MeiliSearchApiError. Error code: {self.code}. Error message: {self.message} Error documentation: {self.link} Error type: {self.type}'
3537

3638
return f'MeiliSearchApiError. {self.message}'
3739

0 commit comments

Comments
 (0)