Java Reference
In-Depth Information
public void addNewSeats() throws Exception {
try {
ticketService.createSeatType(newSeatType);
final FacesMessage m = new
FacesMessage(FacesMessage.SEVERITY_INFO, "Done!", "Seats
Added");
facesContext.addMessage(null, m);
initNewSeatType();
} catch (Exception e) {
final String errorMessage =
getRootErrorMessage(e);
FacesMessage m = new
FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessage,
"Error while saving data");
facesContext.addMessage(null, m);
}
}
private String getRootErrorMessage(Exception e) {
// Default to general error message that
registration failed.
String errorMessage = "Registration failed. See
server log for more information";
if (e == null) {
// This shouldn't happen, but return the
default messages
return errorMessage;
}
// Start with the exception and recurse to find the
root cause
Throwable t = e;
while (t != null) {
// Get the message from the Throwable class
instance
errorMessage = t.getLocalizedMessage();
t = t.getCause();
Search WWH ::




Custom Search