diff --git a/src/open_inwoner/haalcentraal/utils.py b/src/open_inwoner/haalcentraal/utils.py index e4099e0da..f17a7dca4 100644 --- a/src/open_inwoner/haalcentraal/utils.py +++ b/src/open_inwoner/haalcentraal/utils.py @@ -39,10 +39,7 @@ def fetch_brp_data(instance, brp_version): headers={"Accept": "application/hal+json"}, verify=False ), ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return {} - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return {} @@ -68,10 +65,7 @@ def fetch_brp_data(instance, brp_version): verify=False, ), ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return {} - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return {} diff --git a/src/open_inwoner/openzaak/cases.py b/src/open_inwoner/openzaak/cases.py index 91a78486b..64c68ae1c 100644 --- a/src/open_inwoner/openzaak/cases.py +++ b/src/open_inwoner/openzaak/cases.py @@ -44,10 +44,7 @@ def fetch_cases(user_bsn: str, max_cases: Optional[int] = 100) -> List[Zaak]: }, }, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -65,10 +62,7 @@ def fetch_single_case(case_uuid: str) -> Optional[Zaak]: try: response = client.retrieve("zaak", uuid=case_uuid) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -88,10 +82,7 @@ def fetch_single_case_information_object(url: str) -> Optional[ZaakInformatieObj try: response = client.retrieve("zaakinformatieobject", url=url) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -104,10 +95,7 @@ def fetch_case_by_url_no_cache(case_url: str) -> Optional[Zaak]: client = build_client("zaak") try: response = client.retrieve("zaak", url=case_url) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -130,10 +118,7 @@ def fetch_case_information_objects(case_url: str) -> List[ZaakInformatieObject]: "params": {"zaak": case_url}, }, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -155,10 +140,7 @@ def fetch_status_history_no_cache(case_url: str) -> List[Status]: try: response = client.list("status", request_kwargs={"params": {"zaak": case_url}}) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -176,10 +158,7 @@ def fetch_single_status(status_url: str) -> Optional[Status]: try: response = client.retrieve("status", url=status_url) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -213,10 +192,7 @@ def fetch_case_roles( "rol", request_kwargs={"params": params}, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -270,10 +246,7 @@ def fetch_case_information_objects_for_case_and_info( }, }, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -291,10 +264,7 @@ def fetch_single_result(result_url: str) -> Optional[Resultaat]: try: response = client.retrieve("result", url=result_url) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -313,10 +283,7 @@ def connect_case_with_document(case_url: str, document_url: str) -> Optional[dic response = client.create( "zaakinformatieobject", {"zaak": case_url, "informatieobject": document_url} ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return diff --git a/src/open_inwoner/openzaak/catalog.py b/src/open_inwoner/openzaak/catalog.py index 55922642e..0685fc984 100644 --- a/src/open_inwoner/openzaak/catalog.py +++ b/src/open_inwoner/openzaak/catalog.py @@ -30,10 +30,7 @@ def fetch_status_types_no_cache(case_type_url: str) -> List[StatusType]: "statustype", request_kwargs={"params": {"zaaktype": case_type_url}}, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -56,10 +53,7 @@ def fetch_result_types_no_cache(case_type_url: str) -> List[ResultaatType]: "resultaattype", request_kwargs={"params": {"zaaktype": case_type_url}}, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -79,10 +73,7 @@ def fetch_single_status_type(status_type_url: str) -> Optional[StatusType]: try: response = client.retrieve("statustype", url=status_type_url) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -104,10 +95,7 @@ def fetch_zaaktypes_no_cache() -> List[ZaakType]: try: response = get_paginated_results(client, "zaaktype") - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -138,10 +126,7 @@ def fetch_case_types_by_identification_no_cache( "zaaktype", request_kwargs={"params": params}, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -174,10 +159,7 @@ def fetch_single_case_type(case_type_url: str) -> Optional[ZaakType]: try: response = client.retrieve("zaaktype", url=case_type_url) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -200,10 +182,7 @@ def fetch_catalogs_no_cache() -> List[Catalogus]: client, "catalogus", ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return [] @@ -228,10 +207,7 @@ def fetch_single_information_object_type( response = client.retrieve( "informatieobjecttype", url=information_object_type_url ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return diff --git a/src/open_inwoner/openzaak/documents.py b/src/open_inwoner/openzaak/documents.py index 2cab4e507..7e5e6c5c9 100644 --- a/src/open_inwoner/openzaak/documents.py +++ b/src/open_inwoner/openzaak/documents.py @@ -14,10 +14,7 @@ from open_inwoner.openzaak.api_models import InformatieObject from open_inwoner.openzaak.clients import build_client -from open_inwoner.openzaak.models import ( - OpenZaakConfig, - ZaakTypeInformatieObjectTypeConfig, -) +from open_inwoner.openzaak.models import OpenZaakConfig from .utils import cache as cache_result @@ -50,10 +47,7 @@ def _fetch_single_information_object( response = client.retrieve("enkelvoudiginformatieobject", url=url) else: response = client.retrieve("enkelvoudiginformatieobject", uuid=uuid) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return @@ -125,10 +119,7 @@ def upload_document( try: response = client.create("enkelvoudiginformatieobject", document_body) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return diff --git a/src/open_inwoner/openzaak/formapi.py b/src/open_inwoner/openzaak/formapi.py index 2afe0ae6a..755249de8 100644 --- a/src/open_inwoner/openzaak/formapi.py +++ b/src/open_inwoner/openzaak/formapi.py @@ -38,10 +38,7 @@ def fetch_open_submissions(bsn: str) -> List[OpenSubmission]: "opensubmission", request_kwargs={"params": {"bsn": bsn}}, ) - except RequestException as e: - logger.exception("exception while making request", exc_info=e) - return [] - except ClientError as e: + except (RequestException, ClientError) as e: logger.exception("exception while making request", exc_info=e) return []