GNXSOFT.COM

This commit is contained in:
Iliyan Angelov
2025-09-26 00:15:37 +03:00
commit fe26b7cca4
16323 changed files with 2011881 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
from django.http import HttpResponse
from .codecs import _OpenAPICodec
from .errors import SwaggerValidationError
class SwaggerExceptionMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
return self.get_response(request)
def process_exception(self, request, exception):
if isinstance(exception, SwaggerValidationError):
err = {'errors': exception.errors, 'message': str(exception)}
codec = exception.source_codec
if isinstance(codec, _OpenAPICodec):
err = codec.encode_error(err)
content_type = codec.media_type
return HttpResponse(err, status=500, content_type=content_type)
return None # pragma: no cover