def get_ckan_error(response):
    """Return the error from a ckan json response, or None."""
    ckan_error = None
    try:
        if not response['success'] and response['error']:
            ckan_error = response['error']
    except TypeError:
        ckan_error = response
    return ckan_error
