<commit_before>import json


class TaigaException(Exception):
    pass


class TaigaRestException(TaigaException):

    def __init__(self, uri, status_code, message="", method='GET'):
        self.uri = uri
        self.status_code = status_code
        self.method = method
        try:
            json_message = json.loads(message)
            if '_error_message' in json_message:
                message = json_message['_error_message']
        except ValueError:
            pass
        super(TaigaRestException, self).__init__(message)<commit_msg>Improve exception string representation (#84)<commit_after>import json


class TaigaException(Exception):
    pass


class TaigaRestException(TaigaException):

    def __init__(self, uri, status_code, message="", method='GET'):
        self.uri = uri
        self.status_code = status_code
        self.method = method
        try:
            json_message = json.loads(message)
            if '_error_message' in json_message:
                message = json_message['_error_message']
        except ValueError:
            pass
        if not message:
            message = 'Status: {} on URI: {}'.format(status_code, uri)
        super(TaigaRestException, self).__init__(message)
{'fraction_non_alphanumeric': 0.09149797570850203, 'fraction_numerical': 0.0016194331983805667, 'mean_word_length': 2.561959654178674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6051203', 'n_tokens_mistral': 342, 'n_tokens_neox': 328, 'n_words': 78}