Skip to content

Commit

Permalink
TRUNK-3956 ~ caught the DataIntegrityViolationException error
Browse files Browse the repository at this point in the history
(cherry picked from commit 996ddca)
  • Loading branch information
k-joseph authored and dkayiwa committed Sep 12, 2013
1 parent 9a0012d commit 3f05b49
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -39,6 +39,7 @@
import org.openmrs.web.WebConstants;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.bind.ServletRequestDataBinder;
Expand Down Expand Up @@ -108,6 +109,10 @@ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse
Context.getFormService().purgeForm(form);
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Form.deleted");
}
catch (DataIntegrityViolationException e) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Form.cannot.delete");
return new ModelAndView(new RedirectView("formEdit.form?formId=" + form.getFormId()));
}
catch (Exception e) {
log.error("Error while deleting form " + form.getFormId(), e);
errors.reject(e.getMessage());
Expand Down

0 comments on commit 3f05b49

Please sign in to comment.