<commit_before>from functools import wraps
from flask import jsonify
from flask_jwt_extended.exceptions import NoAuthorizationError
from flask_rollbar import Rollbar
from werkzeug.exceptions import (
    BadRequest, Unauthorized, Forbidden, NotFound,
    UnprocessableEntity, MethodNotAllowed, UnsupportedMediaType
)

rollbar = Rollbar(ignore_exc=[BadRequest, Unauthorized, Forbidden, NotFound, UnprocessableEntity,
                              MethodNotAllowed, UnsupportedMediaType,
                              NoAuthorizationError])


def get_http_exception_handler(app):
    """Overrides the default http exception handler to return JSON."""
    handle_http_exception = app.handle_http_exception

    @wraps(handle_http_exception)
    def ret_val(exception):
        exc = handle_http_exception(exception)
        data = {
            'code': exc.code,
            'message': exc.description
        }

        return jsonify(data), exc.code

    return ret_val<commit_msg>Ignore conflict errors in rollbar<commit_after>from functools import wraps
from flask import jsonify
from flask_jwt_extended.exceptions import NoAuthorizationError
from flask_rollbar import Rollbar
from werkzeug.exceptions import (
    BadRequest, Unauthorized, Forbidden, NotFound,
    UnprocessableEntity, MethodNotAllowed, UnsupportedMediaType,
    Conflict)

rollbar = Rollbar(ignore_exc=[BadRequest, Unauthorized, Forbidden, NotFound, UnprocessableEntity,
                              MethodNotAllowed, UnsupportedMediaType, Conflict,
                              NoAuthorizationError])


def get_http_exception_handler(app):
    """Overrides the default http exception handler to return JSON."""
    handle_http_exception = app.handle_http_exception

    @wraps(handle_http_exception)
    def ret_val(exception):
        exc = handle_http_exception(exception)
        data = {
            'code': exc.code,
            'message': exc.description
        }

        return jsonify(data), exc.code

    return ret_val
{'fraction_non_alphanumeric': 0.06390414378432352, 'fraction_numerical': 0.0, 'mean_word_length': 3.3189655172413794, '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': '2094476', 'n_tokens_mistral': 531, 'n_tokens_neox': 528, 'n_words': 131}