# Path: certificate_engine/ssl/certificate.py
# class PolicyError(ValueError):
#     """Base class for policy errors in this module."""
# 
#     pass


from django.core.exceptions import ValidationError as DjangoValidationError
from rest_framework import serializers
from certificate_engine.ssl.certificate import PolicyError
"""Create serializer validation errors from django validation errors for automatic handling"""




class TrapDjangoValidationErrorCreateMixin(object):
    def perform_create(self, serializer):
        try:
            serializer.save()
        except DjangoValidationError as detail:
            raise serializers.ValidationError({"non_field_errors": detail.messages})

# Path: certificate_engine/ssl/certificate.py
# class PolicyError(ValueError):
#     """Base class for policy errors in this module."""
# 
#     pass


# Path: api/mixins.py
from django.core.exceptions import ValidationError as DjangoValidationError
from rest_framework import serializers
from certificate_engine.ssl.certificate import PolicyError

"""Create serializer validation errors from django validation errors for automatic handling"""




class TrapDjangoValidationErrorCreateMixin(object):
    def perform_create(self, serializer):
        try:
            serializer.save()
        except DjangoValidationError as detail:
            raise serializers.ValidationError({"non_field_errors": detail.messages})

        except PolicyError as detail: