# Path: rhizi/rz_kernel.py
# class RZDoc_Exception__not_found(Exception):
# 
#     def __init__(self, rzdoc_name):
#         super(RZDoc_Exception__not_found, self).__init__('rzdoc not found: \'%s\'' % (rzdoc_name))
#         self.rzdoc_name = rzdoc_name


import sys
import json
import logging
from functools import wraps
from flask import make_response
from werkzeug.wrappers import BaseResponse as Response
from .rz_api_common import API_Exception__bad_request
from .rz_kernel import RZDoc_Exception__not_found
    ret_data = __response_wrap(data, error_str)
    resp_payload = json.dumps(ret_data)
    resp = Response(resp_payload, mimetype='application/json', status=status)
    resp.headers['Access-Control-Allow-Origin'] = '*'

    # more response processing
    return resp


def common_resp_handle__success(data=None, error=None, status=200):
    return __common_resp_handle(data, error, status)

def common_resp_handle__redirect(data=None, error=None, status=300):
    return __common_resp_handle(data, error, status)

def common_resp_handle__client_error(data=None, error=None, status=400):
    return __common_resp_handle(data, error, status)

def common_resp_handle__server_error(data=None, error=None, status=500):
    return __common_resp_handle(data, error, status)

def common_rest_req_exception_handler(rest_API_endpoint):

    @wraps(rest_API_endpoint)
    def rest_API_endpoint__decorated(*args, **kwargs):
        try:
            return rest_API_endpoint(*args, **kwargs)
        except API_Exception__bad_request as e:
            log.exception(e)
            return common_resp_handle__client_error(error=e)  # currently blame client for all DNFs

# Path: rhizi/rz_kernel.py
# class RZDoc_Exception__not_found(Exception):
# 
#     def __init__(self, rzdoc_name):
#         super(RZDoc_Exception__not_found, self).__init__('rzdoc not found: \'%s\'' % (rzdoc_name))
#         self.rzdoc_name = rzdoc_name


# Path: rhizi/rz_req_handling.py
import sys
import json
import logging
from functools import wraps
from flask import make_response
from werkzeug.wrappers import BaseResponse as Response
from .rz_api_common import API_Exception__bad_request
from .rz_kernel import RZDoc_Exception__not_found

    ret_data = __response_wrap(data, error_str)
    resp_payload = json.dumps(ret_data)
    resp = Response(resp_payload, mimetype='application/json', status=status)
    resp.headers['Access-Control-Allow-Origin'] = '*'

    # more response processing
    return resp


def common_resp_handle__success(data=None, error=None, status=200):
    return __common_resp_handle(data, error, status)

def common_resp_handle__redirect(data=None, error=None, status=300):
    return __common_resp_handle(data, error, status)

def common_resp_handle__client_error(data=None, error=None, status=400):
    return __common_resp_handle(data, error, status)

def common_resp_handle__server_error(data=None, error=None, status=500):
    return __common_resp_handle(data, error, status)

def common_rest_req_exception_handler(rest_API_endpoint):

    @wraps(rest_API_endpoint)
    def rest_API_endpoint__decorated(*args, **kwargs):
        try:
            return rest_API_endpoint(*args, **kwargs)
        except API_Exception__bad_request as e:
            log.exception(e)
            return common_resp_handle__client_error(error=e)  # currently blame client for all DNFs

        except RZDoc_Exception__not_found as e: