File size: 1,012 Bytes
095b5f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85dd209
 
 
2213315
 
095b5f1
 
 
 
 
 
2213315
 
095b5f1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# myapp/exception_handler.py

from typing import Dict
from rest_framework.views import exception_handler
import logging

from _utils.bubble_integrations.enviar_resposta_final import enviar_resposta_final

logger = logging.getLogger(__name__)


def custom_exception_handler(exc, context):
    # Call REST framework's default exception handler first
    response = exception_handler(exc, context)
    serializer: Dict = context["view"].serializer

    if response and str(response.status_code)[0] != "2":
        logger.error(f"Validation error: {response.data}")

    print("INICIANDO RESPOSTA DE ERRO PARA O BUBBLE")
    resposta_bubble = enviar_resposta_final(
        serializer.get("doc_id", ""),
        serializer.get("form_response_id", ""),
        serializer.get("version", ""),
        serializer.get("texto_completo", ""),
        True,
    )
    print("\n\nresposta_bubble.status_code", resposta_bubble.status_code)
    print("\n\nresposta_bubble.json()", resposta_bubble.json())

    return response