Skip to content

Commit 224ba77

Browse files
authored
Formatting response bodies (#56)
1 parent b6ec0ae commit 224ba77

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

arangoasync/aql.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ async def explain(
597597
def response_handler(resp: Response) -> Json:
598598
if not resp.is_success:
599599
raise AQLQueryExplainError(resp, request)
600-
return self.deserializer.loads(resp.raw_body)
600+
return Response.format_body(self.deserializer.loads(resp.raw_body))
601601

602602
return await self._executor.execute(request, response_handler)
603603

@@ -625,7 +625,7 @@ async def validate(self, query: str) -> Result[Json]:
625625
def response_handler(resp: Response) -> Json:
626626
if not resp.is_success:
627627
raise AQLQueryValidateError(resp, request)
628-
return self.deserializer.loads(resp.raw_body)
628+
return Response.format_body(self.deserializer.loads(resp.raw_body))
629629

630630
return await self._executor.execute(request, response_handler)
631631

@@ -719,7 +719,7 @@ async def create_function(
719719
def response_handler(resp: Response) -> Json:
720720
if not resp.is_success:
721721
raise AQLFunctionCreateError(resp, request)
722-
return self.deserializer.loads(resp.raw_body)
722+
return Response.format_body(self.deserializer.loads(resp.raw_body))
723723

724724
return await self._executor.execute(request, response_handler)
725725

@@ -760,6 +760,6 @@ def response_handler(resp: Response) -> Json:
760760
if not resp.is_success:
761761
if not (resp.status_code == HTTP_NOT_FOUND and ignore_missing):
762762
raise AQLFunctionDeleteError(resp, request)
763-
return self.deserializer.loads(resp.raw_body)
763+
return Response.format_body(self.deserializer.loads(resp.raw_body))
764764

765765
return await self._executor.execute(request, response_handler)

arangoasync/collection.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,10 +2592,7 @@ async def edges(
25922592
def response_handler(resp: Response) -> Json:
25932593
if not resp.is_success:
25942594
raise EdgeListError(resp, request)
2595-
body = self.deserializer.loads(resp.raw_body)
2596-
for key in ("error", "code"):
2597-
body.pop(key)
2598-
return body
2595+
return Response.format_body(self.deserializer.loads(resp.raw_body))
25992596

26002597
return await self._executor.execute(request, response_handler)
26012598

arangoasync/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ async def view(self, name: str) -> Result[Json]:
12551255
def response_handler(resp: Response) -> Json:
12561256
if not resp.is_success:
12571257
raise ViewGetError(resp, request)
1258-
return self.deserializer.loads(resp.raw_body)
1258+
return Response.format_body(self.deserializer.loads(resp.raw_body))
12591259

12601260
return await self._executor.execute(request, response_handler)
12611261

@@ -1280,7 +1280,7 @@ async def view_info(self, name: str) -> Result[Json]:
12801280
def response_handler(resp: Response) -> Json:
12811281
if not resp.is_success:
12821282
raise ViewGetError(resp, request)
1283-
return self.deserializer.loads(resp.raw_body)
1283+
return Response.format_body(self.deserializer.loads(resp.raw_body))
12841284

12851285
return await self._executor.execute(request, response_handler)
12861286

@@ -2006,7 +2006,7 @@ def response_handler(resp: Response) -> Json:
20062006
if not resp.is_success:
20072007
raise JWTSecretListError(resp, request)
20082008
result: Json = self.deserializer.loads(resp.raw_body)
2009-
return result
2009+
return Response.format_body(result)
20102010

20112011
return await self._executor.execute(request, response_handler)
20122012

@@ -2028,7 +2028,7 @@ def response_handler(resp: Response) -> Json:
20282028
if not resp.is_success:
20292029
raise JWTSecretReloadError(resp, request)
20302030
result: Json = self.deserializer.loads(resp.raw_body)
2031-
return result
2031+
return Response.format_body(result)
20322032

20332033
return await self._executor.execute(request, response_handler)
20342034

0 commit comments

Comments
 (0)