def build_cores(cores, solr_cores):
    """
    Builds a list of cores to search based on given parameters.
    Raises an exception if any core is not available.
    """
    if cores == '':
        return solr_cores
    
    if cores == 'test':
        return ['test']
    
    core_list = cores.split(',')
    invalid_core_list = [core for core in core_list if core not in solr_cores]
    if len(invalid_core_list) > 0:
        raise ValueError('Invalid type(s) requested: ' + ','.join(invalid_core_list))
        
    return core_list