Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 9213795

Browse files
author
Martin Wahnschaffe
authored
Merge pull request SORMAS-Foundation#3635 from hzi-braunschweig/bugfix-3495-campaign-validation-error-messages
SORMAS-Foundation#3495 - Catch additional exceptions and present them to the user
2 parents 22f3f4f + bf72218 commit 9213795

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface Validations {
2626
String campaignFormElementNotExisting = "campaignFormElementNotExisting";
2727
String campaignFormElementTypeRequired = "campaignFormElementTypeRequired";
2828
String campaignFormInvalidIdInListElements = "campaignFormInvalidIdInListElements";
29+
String campaignFormMetaValidationUnexpectedError = "campaignFormMetaValidationUnexpectedError";
2930
String campaignFormTranslationCaptionRequired = "campaignFormTranslationCaptionRequired";
3031
String campaignFormTranslationIdInvalid = "campaignFormTranslationIdInvalid";
3132
String campaignFormTranslationIdRequired = "campaignFormTranslationIdRequired";

sormas-api/src/main/resources/validations.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ externalJournalPersonValidationPhone = Invalid phone number.
138138
externalJournalPersonValidationPhoneTaken = The phone number is already in use in the symptom journal.
139139
externalJournalPersonValidationEmailTaken = The email address is already in use in the symptom journal.
140140
externalJournalPersonValidationNoEmailOrPhone = Please provide an email address or a phone number.
141+
campaignFormMetaValidationUnexpectedError = There was an unexpected error while trying to validate this form. Please forward the following error message to a system administrator: %s

sormas-backend/src/main/java/de/symeda/sormas/backend/campaign/form/CampaignFormMetaFacadeEjb.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,25 @@ public List<CampaignFormMetaDto> getByUuids(List<String> uuids) {
143143
return service.getByUuids(uuids).stream().map(campaignFormMeta -> toDto(campaignFormMeta)).collect(Collectors.toList());
144144
}
145145

146-
@Override
147-
public List<CampaignFormMetaReferenceDto> getCampaignFormMetasAsReferencesByCampaign(String uuid) {
148-
return service.getCampaignFormMetasAsReferencesByCampaign(uuid);
149-
}
146+
@Override
147+
public List<CampaignFormMetaReferenceDto> getCampaignFormMetasAsReferencesByCampaign(String uuid) {
148+
return service.getCampaignFormMetasAsReferencesByCampaign(uuid);
149+
}
150150

151151
@Override
152-
public void validateAllFormMetas() {
153-
List<CampaignFormMeta> forms = service.getAll();
152+
public void validateAllFormMetas() {
153+
List<CampaignFormMeta> forms = service.getAll();
154154

155155
for (CampaignFormMeta form : forms) {
156156
try {
157157
CampaignFormMetaDto formDto = toDto(form);
158158
validateAndClean(formDto);
159159
} catch (ValidationRuntimeException e) {
160-
throw new ValidationRuntimeException(form.getId() + ": " + e.getMessage());
160+
throw new ValidationRuntimeException(form.getFormId() + ": " + e.getMessage());
161+
} catch (Exception e) {
162+
throw new ValidationRuntimeException(
163+
form.getFormId() + ": "
164+
+ I18nProperties.getValidationError(Validations.campaignFormMetaValidationUnexpectedError, e.getMessage()));
161165
}
162166
}
163167
}

0 commit comments

Comments
 (0)