declex icon indicating copy to clipboard operation
declex copied to clipboard

Action processing error when returning bools

Open smaugho opened this issue 6 years ago • 1 comments

When this method is processed:

  protected Boolean validateTutorOperation() {
        User_ currentUser = authenticateManager.getCurrentUser();
        if (currentUser == null) {
            {$TutorDataError("Only a logged in user can create lessons");}
            return false;
        } else if (!currentUser.isTeacher()) {
            {$TutorDataError("Only a tutors can create lessons");}
            return false;
        }

        return true;
    }

The actions processers generates multiple errors due to the returns.

smaugho avatar Aug 13 '17 11:08 smaugho

To bypass the error for now, I had to call the action in another method, like this:

    protected Boolean validateTutorOperation() {
        User_ currentUser = authenticateManager.getCurrentUser();
        if (currentUser == null) {
            sendError("Only a logged in user can create lessons");
            return false;
        } else if (!currentUser.isTeacher()) {
            sendError("Only a tutors can create lessons");
            return false;
        }

        return true;
    }

    protected void sendError(String errorMessage) {
        $TutorDataError(errorMessage);
    }

smaugho avatar Aug 13 '17 11:08 smaugho