Skip to content

Commit 952aeb3

Browse files
committed
added 'not' and returning reason if it exists and error does not exist in data
1 parent 1cf9bbf commit 952aeb3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/superannotate/lib/core/service_types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, response, content_type=None):
8080
"content": response.content,
8181
}
8282
if response.ok:
83-
if content_type and not content_type is self.__class__:
83+
if content_type and not content_type is not self.__class__:
8484
data["data"] = content_type(**response.json())
8585
else:
8686
data["data"] = response.json()
@@ -92,4 +92,5 @@ def ok(self):
9292

9393
@property
9494
def error(self):
95-
return getattr(self.data, "error", "Unknown error.")
95+
default_message = self.reason if self.reason else "Unknown Error"
96+
return getattr(self.data, "error", default_message)

0 commit comments

Comments
 (0)