Show validation error messages in mapping step

This commit is contained in:
Jan Böhmer 2025-09-06 23:10:47 +02:00
parent 72e3766be5
commit 1d33d95c57

View file

@ -378,7 +378,7 @@ class ProjectController extends AbstractController
} }
// If there are validation errors, show them and stop // If there are validation errors, show them and stop
if (!empty($validation_result['errors'])) { if (!empty($validation_result['errors'])) {
foreach ($validation_result['errors'] as $error) { foreach ($validation_result['errors'] as $error) {
$this->addFlash('error', $error); $this->addFlash('error', $error);
} }
@ -449,6 +449,16 @@ class ProjectController extends AbstractController
// When we get here, there were validation errors // When we get here, there were validation errors
$this->addFlash('error', t('project.bom_import.flash.invalid_entries')); $this->addFlash('error', t('project.bom_import.flash.invalid_entries'));
//Print validation errors to log for debugging
foreach ($errors as $error) {
$logger->error('BOM entry validation error', [
'message' => $error->getMessage(),
'invalid_value' => $error->getInvalidValue(),
]);
//And show as flash message
$this->addFlash('error', $error->getMessage(),);
}
} catch (\UnexpectedValueException | SyntaxError $e) { } catch (\UnexpectedValueException | SyntaxError $e) {
$this->addFlash('error', t('project.bom_import.flash.invalid_file', ['%message%' => $e->getMessage()])); $this->addFlash('error', t('project.bom_import.flash.invalid_file', ['%message%' => $e->getMessage()]));
} }