From ee2bc6a2ed701039b5d1837bef36610ec1794e30 Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Mon, 24 Jun 2024 10:34:27 +0200 Subject: [PATCH] Added error handling for facility sync --- .../app/application/synchronization/facilities.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sigeca_data_import_microservice/app/application/synchronization/facilities.py b/sigeca_data_import_microservice/app/application/synchronization/facilities.py index de5592c..7968180 100644 --- a/sigeca_data_import_microservice/app/application/synchronization/facilities.py +++ b/sigeca_data_import_microservice/app/application/synchronization/facilities.py @@ -246,13 +246,22 @@ def format_payload_f(self): return format_payload_f def _create_request(self, data): - self.lmis_client.send_post_request("facilities", data["payload"]) + try: + self.lmis_client.send_post_request("facilities", data["payload"]) + except Exception as e: + logging.error(f"An error occurred during facility creation request ({data}): {e}") def _update_request(self, data): - self.lmis_client.send_put_request("facilities", data["id"], data["payload"]) + try: + self.lmis_client.send_put_request("facilities", data["id"], data["payload"]) + except Exception as e: + logging.error(f"An error occurred during facility update request ({data}): {e}") def _delete_request(self, data): - self.lmis_client.send_delete_request("facilities", data["id"]) + try: + self.lmis_client.send_delete_request("facilities", data["id"]) + except Exception as e: + logging.error(f"An error occurred during facility delete request ({data}): {e}") def _update_existing_facilities(self, facilities: DataFrame): format_payload_f = self.format_payload_f()