Skip to content

Commit 3a73310

Browse files
committed
refactor!: make Haystack errors contain Grid response
1 parent 13ec574 commit 3a73310

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

phable/client.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class UnknownRecError(Exception):
2626

2727
@dataclass
2828
class ErrorGridResponseError(Exception):
29-
help_msg: str
29+
response: Grid
3030

3131

3232
@dataclass
3333
class IncompleteDataResponseError(Exception):
34-
help_msg: str
34+
response: Grid
3535

3636

3737
class Client:
@@ -674,7 +674,7 @@ def _call(
674674
headers=headers,
675675
context=self._context,
676676
)
677-
_validate_response_meta(response.meta)
677+
_validate_response_meta(response)
678678

679679
return response
680680

@@ -704,18 +704,14 @@ def _validate_his_write_parameters(
704704
)
705705

706706

707-
def _validate_response_meta(meta: dict[str, Any]):
707+
def _validate_response_meta(response: Grid):
708+
709+
meta = response.meta
708710
if "err" in meta.keys():
709-
error_dis = meta["dis"]
710-
raise ErrorGridResponseError(
711-
"The server returned an error grid with this message:\n" + error_dis
712-
)
711+
raise ErrorGridResponseError(response)
713712

714713
if "incomplete" in meta.keys():
715-
incomplete_dis = meta["incomplete"]
716-
raise IncompleteDataResponseError(
717-
"Incomplete data was returned for these reasons:" f"\n{incomplete_dis}"
718-
)
714+
raise IncompleteDataResponseError(response)
719715

720716

721717
def _create_his_read_req_data(

0 commit comments

Comments
 (0)