def METHOD_NAME(exception):
    exception_json_formatter = next((f for exc, f in EXCEPTION_JSON_MAP.items() if isinstance(exception, exc)), None)
    if exception_json_formatter:
        return exception_json_formatter(exception)
    message_func = next((f for exc, f in EXCEPTION_MESSAGE_MAP.items() if isinstance(exception, exc)), str)
    return {'error': message_func(exception)}