"""

"""

from rest_framework.views import exception_handler
from rest_framework.response import Response
from rest_framework import status

def conflict_exception_handler(exc, context):
    response = exception_handler(exc, context)
        
    if response is not None and isinstance(response.data, dict):
        for errors in response.data.values():
            if not isinstance(errors, list):
                continue
            
            for error in errors:
                if hasattr(error, 'code') and error.code == 'unique':
                    response.status_code = status.HTTP_409_CONFLICT
                    return response

    return response