mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
fix: validation error messages hidden by generic fallback in ErrorHandler::userMessage
ErrorHandler::userMessage only handled RuntimeException, but all validation throws in ThesisCreateController and ThesisEditController use plain Exception. This caused user-friendly messages like 'Le champ Nom/Prénom/Pseudo est requis' to fall through to the 'Une erreur inattendue est survenue…' generic message. Fix: add Exception check (after PDOException, since PDOException extends it) so all validation exceptions pass their message through.
This commit is contained in:
@@ -231,10 +231,10 @@ class ThesisCreateController
|
||||
*/
|
||||
public static function autofocusFieldForError(string $message): ?string
|
||||
{
|
||||
if (str_contains($message, 'Nom/Prénom/Pseudo')) {
|
||||
if (str_contains($message, "Auteur·ice")) {
|
||||
return 'auteurice';
|
||||
}
|
||||
if (str_contains($message, 'Titre du mémoire')) {
|
||||
if (str_contains($message, 'Titre du TFE')) {
|
||||
return 'titre';
|
||||
}
|
||||
if (str_contains($message, 'Synopsis')) {
|
||||
@@ -302,7 +302,7 @@ class ThesisCreateController
|
||||
sort($authorNames, SORT_NATURAL);
|
||||
}
|
||||
if (empty($authorNames)) {
|
||||
throw new Exception("Le champ 'Nom/Prénom/Pseudo' est requis.");
|
||||
throw new Exception("Le champ 'Auteur·ice(s)' est requis.");
|
||||
}
|
||||
|
||||
// contact_interne (backoffice) takes precedence over mail (tfe-info fieldset)
|
||||
@@ -339,7 +339,7 @@ class ThesisCreateController
|
||||
throw new Exception('Veuillez sélectionner une finalité.');
|
||||
}
|
||||
|
||||
$titre = $this->validateRequired($this->sanitiseString($post['titre'] ?? ''), 'Titre du mémoire');
|
||||
$titre = $this->validateRequired($this->sanitiseString($post['titre'] ?? ''), 'Titre du TFE');
|
||||
$subtitle = $this->sanitiseString($post['subtitle'] ?? '');
|
||||
$synopsis = $this->validateRequired($this->sanitiseString($post['synopsis'] ?? ''), 'Synopsis');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user