<commit_before># -*- coding: utf-8 -*-


class FieldError(Exception):
    pass<commit_msg>Added JSONAPIError exception<commit_after># -*- coding: utf-8 -*-


class FieldError(Exception):
    pass


class JSONAPIError(Exception):

    def __init__(self, message, code=400):
        """Format the error's message to match the JSONAPI 1.0 spec.

        :param message: A list errors or a string message.
        :param code: HTTP status code.
        """
        data = {'status': code}
        if isinstance(message, str):
            data.update({'errors': {'detail': message}})
        else:
            data.update({'errors': message})
        self.message = data
        super(JSONAPIError, self).__init__(data)
{'fraction_non_alphanumeric': 0.13165266106442577, 'fraction_numerical': 0.00980392156862745, 'mean_word_length': 2.575, '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': '6933589', 'n_tokens_mistral': 205, 'n_tokens_neox': 195, 'n_words': 59}