def METHOD_NAME(self, for_domain, for_case_type, for_db_conn):
    if for_case_type:
        available_case_types = (CommCareCase.objects.using(for_db_conn).
                                values_list('type', flat=True).distinct())
        if for_case_type not in available_case_types:
            raise CommandError("Unexpected case type {for_case_type} passed. "
                               "Should be from the following: {case_types}"
                               .format(for_case_type=for_case_type, case_types=available_case_types))
    if for_domain:
        available_domains = (CommCareCase.objects.using(for_db_conn).
                             values_list('domain', flat=True).distinct())
        if for_domain not in available_domains:
            raise CommandError("Domain name {for_domain} not found for any case in db {for_db_conn}".format(
                for_domain=for_domain, for_db_conn=for_db_conn
            ))