<commit_before>"""This module contains error handler utility functions."""

from flask import Blueprint
from flask.json import jsonify

errors = Blueprint('errors', __name__)


@errors.app_errorhandler(404)
def not_found(e):
    """404 Error Handler."""
    return generic_errors("Not found", code=404)


@errors.app_errorhandler(500)
def server_error(e):
    """500 Error Handler."""
    return generic_errors("server error", code=500)


@errors.app_errorhandler(405)
def method_error(e):
    """405 Error Handler."""
    return generic_errors("method not allowed", code=405)


@errors.app_errorhandler(ValueError)
def handle_invalid_arguments(e):
    """Handle malformed request data errors."""
    errors = e.message
    return generic_errors(errors, code=400)

<commit_msg>[Fix: #147219801] Handle Exceptions from app - Add handle ValueError exception from missing data<commit_after>"""This module contains error handler utility functions."""

from flask import Blueprint
from flask.json import jsonify

errors = Blueprint('errors', __name__)


@errors.app_errorhandler(Exception)
def handle_exceptions(e):
    return {"message": "exception occured"}


@errors.app_errorhandler(404)
def not_found(e):
    """404 Error Handler."""
    return generic_errors("Not found", code=404)


@errors.app_errorhandler(500)
def server_error(e):
    """500 Error Handler."""
    return generic_errors("server error", code=500)


@errors.app_errorhandler(405)
def method_error(e):
    """405 Error Handler."""
    return generic_errors("method not allowed", code=405)


@errors.app_errorhandler(ValueError)
def handle_invalid_arguments(e):
    """Handle malformed request data errors."""
    errors = e.message
    return generic_errors(errors, code=400)


{'fraction_non_alphanumeric': 0.12206303724928366, 'fraction_numerical': 0.03954154727793696, 'mean_word_length': 5.395604395604396, 'pattern_counts': {'":': 1, '<': 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': '1591655', 'n_tokens_mistral': 564, 'n_tokens_neox': 498, 'n_words': 143}