def METHOD_NAME(self, cmd_example=None, noerror=False, varname='environment_name'):
    env_name = getattr(self.app.pargs, varname, None)
    if not env_name:
        env_name = commonops. \
            get_current_branch_environment()
    workspace_type = fileoperations.get_workspace_type(Constants.WorkSpaceTypes.APPLICATION)
    if not env_name:
        if Constants.WorkSpaceTypes.PLATFORM == workspace_type:
            raise EBCLIException(strings['platform.nobuilderenv'])
        if noerror:
            return None
        if not cmd_example:
            message = strings['branch.noenv'].replace('{cmd}',
                                                      self.Meta.label)
        else:
            message = strings['branch.noenv'].replace('eb {cmd}',
                                                      cmd_example)
        io.log_error(message)
        raise NoEnvironmentForBranchError()
    return env_name