def handle_type_error(fn):
    """
    Convert ``TypeError`` to ``bottle.HTTPError`` with ``400`` code and message
    about wrong parameters.

    Raises:
        HTTPError: 400 in case too many/too little function parameters were \
                   given.
    """
    @wraps(fn)
    def handle_type_error_wrapper(*args, **kwargs):
        def any_match(string_list, obj):
            return filter(lambda x: x in obj, string_list)

        try:
            return fn(*args, **kwargs)
        except __HOLE__ as e:
            str_list = [
                "takes exactly",
                "got an unexpected",
                "takes no argument",
            ]
            if fn.__name__ in e.message and any_match(str_list, e.message):
                raise HTTPError(400, e.message)

            raise  # This will cause 500: Internal server error

    return handle_type_error_wrapper
dataset/ETHPy150Open Bystroushaak/bottle-rest/src/bottle_rest/bottle_rest.py/handle_type_error