def METHOD_NAME(response, status, message, ex_type):
    err_dct = {
        'message': message,
        'type': str(ex_type.__name__),
        'code': ex_type.get_code(),
    }
    response.body = json.dumps({'error': err_dct}).encode()
    response.status = status
    response.close_connection = True