'Extract the actual error message from a solr response.'

def _extract_error(self, resp):

    reason = resp.headers.get(u'reason', None)
    full_response = None
    if (reason is None):
        try:
            reason = resp.json()[u'error'][u'msg']
        except KeyError:
            full_response = resp.content
        except ValueError:
            (reason, full_html) = self._scrape_response(resp.headers, resp.content)
            full_response = unescape_html(full_html)
    msg = (u'[Reason:    %s]' % reason)
    if (reason is None):
        msg += (u'\n%s' % full_response)
    return msg
