Skip to content

Commit

Permalink
Collecting the exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sherrif10 committed Feb 10, 2021
1 parent 37aa36a commit 6c7e64a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
import org.openmrs.ui.framework.annotation.SpringBean;
import org.openmrs.ui.framework.page.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.WebRequest;

public class ViewEncounterWithHtmlFormPageController {

Expand Down Expand Up @@ -65,13 +69,10 @@ public void get(@RequestParam("encounter") Encounter encounter,
model.addAttribute("showPatientHeader", showPatientHeader);

HtmlForm htmlForm = htmlFormEntryService.getHtmlFormByForm(encounter.getForm());
// HttpSession session = request.getSession();

if (htmlForm == null) {
// HttpSession session = request.getSession();
message = messageSourceService.getMessage("encounter.form is not an HTML Form" +encounter.getForm());
log.warn("Active drugs are not supported yet");
// session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, message);
// throw new IllegalArgumentException("encounter.form is not an HTML Form: " + encounter.getForm());
log.warn("Active drugs are cannot be editted");
model.addAttribute("htmlForm", htmlForm);


Expand All @@ -87,10 +88,11 @@ private String fixCase(String word) {
return Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase();
}

@ExceptionHandler(value= NullPointerException.class)
public String HandleNullPointerException(Exception e) {
log.warn(message);
@ExceptionHandler(value= NullPointerException.class)
public String HandleNullPointerException(Exception e) {
log.warn("encounter.form is not an HTML Form");
return "NullPointerException";
}
}


}
5 changes: 5 additions & 0 deletions omod/src/main/webapp/pages/htmlform/NullPointerException.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<% out << " ooppsss!!!! Active drugs cannot be edittted!" %>
</body>
</html>

0 comments on commit 6c7e64a

Please sign in to comment.