From 0b2b893ed3a881e53fe322a16ede52c0e052b4f5 Mon Sep 17 00:00:00 2001 From: remyvdwereld <86827854+remyvdwereld@users.noreply.github.com> Date: Fri, 20 Oct 2023 22:27:41 +0200 Subject: [PATCH] 96116 --- app/apps/addresses/models.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/apps/addresses/models.py b/app/apps/addresses/models.py index b60803c4a..813129bcd 100644 --- a/app/apps/addresses/models.py +++ b/app/apps/addresses/models.py @@ -1,3 +1,5 @@ +import logging + from django.db import models from utils.api_queries_bag import ( do_bag_search_by_bag_id, @@ -6,6 +8,8 @@ get_bag_data_by_verblijfsobject_url, ) +logger = logging.getLogger(__name__) + class District(models.Model): name = models.CharField(max_length=255, unique=True) @@ -162,6 +166,13 @@ def search_and_set_bag_nummeraanduiding_id(self): def save(self, *args, **kwargs): self.search_and_set_bag_address_data() - self.search_and_set_bag_nummeraanduiding_id() + # Prevent a nummeraanduiding_id error while creating a case. + try: + self.search_and_set_bag_nummeraanduiding_id() + except Exception as e: + logger.error( + f"Could not retrieve nummeraanduiding_id for bag_id:{self.bag_id}: {e}" + ) + # TODO: If self is missing address data, don't create a case. return super().save(*args, **kwargs)