From 04d73d68273b69702fc193385e2a5bbe0ec0cb07 Mon Sep 17 00:00:00 2001 From: Alaeddine Abdessalem Date: Tue, 18 Oct 2022 17:20:15 +0100 Subject: [PATCH 1/3] feat: show server error message in push --- docarray/array/mixins/io/pushpull.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index 52e937a8e89..2b78b820955 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -250,6 +250,8 @@ def _get_chunk(_batch): if response.ok: return response.json()['data'] else: + if response.status_code == 403: + response.reason = response.json()['message'] response.raise_for_status() @classmethod From c7f87dbf63035836f0b3c0e5b90b14e3bb5cf9d0 Mon Sep 17 00:00:00 2001 From: Alaeddine Abdessalem Date: Wed, 19 Oct 2022 08:12:29 +0100 Subject: [PATCH 2/3] chore: use constant status --- docarray/array/mixins/io/pushpull.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index 2b78b820955..d694d5c1dbf 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -3,6 +3,7 @@ import os.path import warnings from collections import Counter +from http import HTTPStatus from pathlib import Path from typing import Dict, Type, TYPE_CHECKING, List, Optional, Any @@ -250,7 +251,7 @@ def _get_chunk(_batch): if response.ok: return response.json()['data'] else: - if response.status_code == 403: + if response.status_code == HTTPStatus.FORBIDDEN: response.reason = response.json()['message'] response.raise_for_status() From b744c2c51235fd2d6a401d68dd2e8be8d3112008 Mon Sep 17 00:00:00 2001 From: Alaeddine Abdessalem Date: Wed, 19 Oct 2022 08:38:30 +0100 Subject: [PATCH 3/3] feat: same strategy for all error code --- docarray/array/mixins/io/pushpull.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docarray/array/mixins/io/pushpull.py b/docarray/array/mixins/io/pushpull.py index d694d5c1dbf..96d71df4f71 100644 --- a/docarray/array/mixins/io/pushpull.py +++ b/docarray/array/mixins/io/pushpull.py @@ -251,8 +251,8 @@ def _get_chunk(_batch): if response.ok: return response.json()['data'] else: - if response.status_code == HTTPStatus.FORBIDDEN: - response.reason = response.json()['message'] + if response.status_code >= 400 and 'readableMessage' in response.json(): + response.reason = response.json()['readableMessage'] response.raise_for_status() @classmethod