boolean hasOneOpen = false; Exception toThrow = null; for (final StudentCurricularPlan studentCurricularPlan : activeStudentCurricularPlans) { final Exception exception = verify(studentCurricularPlan); hasOneOpen = hasOneOpen || exception == null; toThrow = exception == null ? toThrow : exception; } if (!hasOneOpen) { throw toThrow; }
    public void execute(ServiceRequest request, ServiceResponse response) throws FilterException, Exception {        Registration registration = getRemoteUser(request).getPerson().getStudentByUsername();        if(registration == null){            registration = getRemoteUser(request).getPerson().getStudentByType(DegreeType.DEGREE);        }                final StudentCurricularPlan studentCurricularPlan = registration.getActiveStudentCurricularPlan();                 if (studentCurricularPlan != null) {        	EnrolmentPeriodInClasses enrolmentPeriodInClasses = studentCurricularPlan.getDegreeCurricularPlan().getCurrentClassesEnrollmentPeriod();            if (enrolmentPeriodInClasses == null || enrolmentPeriodInClasses.getStartDateDateTime() == null                    || enrolmentPeriodInClasses.getEndDateDateTime() == null) {                throw new CurrentClassesEnrolmentPeriodUndefinedForDegreeCurricularPlan();            }            Date now = new Date();            Date startDate = enrolmentPeriodInClasses.getStartDate();            Date endDate = enrolmentPeriodInClasses.getEndDate();                        if(DateFormatUtil.compareDates(comparableDateFormatString, startDate, now) > 0 || DateFormatUtil.compareDates(comparableDateFormatString, endDate, now) < 0) {                 String startDateString = outputDateFormat.format(startDate);                String endDateString = outputDateFormat.format(endDate);                StringBuilder buffer = new StringBuilder();                buffer.append(startDateString);                buffer.append(" - ");                buffer.append(endDateString);                throw new OutsideOfCurrentClassesEnrolmentPeriodForDegreeCurricularPlan(buffer                        .toString());            }        } else {            throw new NoActiveStudentCurricularPlanOfCorrectTypeException();        }    }