import requests
import json


def get_entry(url):
    """Call query URL and check returned entry

    Parameters
    ----------
    url : str
        POWER query URL

    Returns
    -------
    dict
        entry returned by query

    Raises
    ------
    RuntimeError
        when API returned error
    """
    r = requests.get(url)
    r.raise_for_status()
    entry = json.loads(r.text)
    for message in entry.get('messages', []):
        if 'Alert' in message:
            raise RuntimeError(message)
    return entry