diff --git a/infrastructure/abri/abri_client.py b/infrastructure/abri/abri_client.py index 9d69efd86..302ec54f8 100644 --- a/infrastructure/abri/abri_client.py +++ b/infrastructure/abri/abri_client.py @@ -10,7 +10,7 @@ from domain.abri.models import ( ) from infrastructure.abri.config import AbriConfig from infrastructure.abri.envelope import serialise_relay_request -from infrastructure.abri.errors import AbriTransportError +from infrastructure.abri.errors import AbriResponseParseError, AbriTransportError STD_JOB_CODE = "SCSEXT" CLIENT_CODE = "HSG" @@ -45,7 +45,10 @@ class AbriClient: response.raise_for_status() except requests.RequestException as error: raise AbriTransportError(str(error)) from error - root = ET.fromstring(response.content) + try: + root = ET.fromstring(response.content) + except ET.ParseError as error: + raise AbriResponseParseError(str(error)) from error if root.tag == "response": return self._parse_rejection(root) job_logged = root.find("Jobs/Job_logged")