error-handling: add global exception handling, guard Bazaar API calls

This commit is contained in:
2026-08-26 03:22:20 +03:30
parent 49d596f077
commit 83435c5a5f
4 changed files with 110 additions and 15 deletions

View File

@@ -216,6 +216,10 @@ REST_FRAMEWORK = {
'rest_framework.permissions.AllowAny',
],
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
# ⚠️ افزوده شده: بدونِ این، exceptionِ ناشناخته (غیر از APIException/
# Http404/PermissionDenied) به‌جای پاسخِ JSON، صفحه‌ی HTML عمومیِ ۵۰۰
# جنگو رو برمی‌گردونه (نگاه کنید به config/exceptions.py).
'EXCEPTION_HANDLER': 'config.exceptions.custom_exception_handler',
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',