Improve document not found error handling

This commit is contained in:
Lorenz Padberg 2022-08-03 11:25:19 +02:00
parent 21413b183a
commit 88a9d98c0a
1 changed files with 15 additions and 12 deletions

View File

@ -88,6 +88,7 @@ def augment_fields(raw_data):
data['value'] = augment_fields(item_data)
if _type == 'cms_document_block':
try:
_value = data['value']
document = CustomDocument.objects.get(id=_value)
value = {
@ -100,6 +101,8 @@ def augment_fields(raw_data):
'display_text': document.display_text
}
data['value'] = value
except CustomDocument.DoesNotExist:
logger.error('CustomDocument {} does not exist'.format(_value))
return raw_data