Example #1
0
  void onValidateFromCreateForm() {

    if (createForm.getHasErrors()) {
      // We get here only if a server-side validator detected an error.
      return;
    }

    try {
      course =
          courseManagerService.createCourse(
              course.getCode(), course.getName(), course.getSummary(), course.getDescription(), 1);
    } catch (RestClientFailureException e) {
      createForm.recordError("Internal error on server.");
      createForm.recordError(e.getMessage());
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
    } catch (Exception e) {
      createForm.recordError(ExceptionUtil.getRootCauseMessage(e));
      // TODO: replace with exception service
      LOG.info("unhandled exception during validation", e);
    }
  }
Example #2
0
  void onValidateFromUpdateForm() {

    if (updateForm.getHasErrors()) {
      // We get here only if a server-side validator detected an error.
      return;
    }

    try {
      courseManagerService.updateCourse(
          course, course.getName(), course.getSummary(), course.getDescription(), 1);
    } catch (RestClientFailureException e) {
      updateForm.recordError("Internal error on server.");
      updateForm.recordError(e.getMessage());
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
    } catch (Exception e) {
      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      updateForm.recordError(ExceptionUtil.getRootCauseMessage(e));
      // TODO: replace with exception service
      LOG.info("unhandled exception during validation", e);
    }
  }