diff --git a/backend/benefit/applications/management/commands/send_ahjo_requests.py b/backend/benefit/applications/management/commands/send_ahjo_requests.py index fcf91761da..e306a23f94 100644 --- a/backend/benefit/applications/management/commands/send_ahjo_requests.py +++ b/backend/benefit/applications/management/commands/send_ahjo_requests.py @@ -18,6 +18,7 @@ AhjoToken, AhjoTokenExpiredException, ) +from applications.services.ahjo_error_writer import AhjoErrorWriter, AhjoFormattedError from applications.services.ahjo_integration import ( delete_application_in_ahjo, get_decision_details_from_ahjo, @@ -154,6 +155,11 @@ def run_requests( except tuple(exception_messages.keys()) as e: error_text = f"{exception_messages[type(e)]} {application.application_number}: {e}" LOGGER.error(error_text) + AhjoErrorWriter.write_to_validation_error( + AhjoFormattedError( + application=application, message_to_handler=error_text + ) + ) failed_applications.append(application) self._handle_failed_request( counter, application, ahjo_request_type, error_text