Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

add logging in case of unsuccessful operation #25

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bridgeql/django/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
from django.views.decorators.http import require_GET


from bridgeql.django import logger
from bridgeql.django.auth import auth_decorator
from bridgeql.django.exceptions import (
ForbiddenModelOrField,
Expand All @@ -28,11 +28,14 @@ def read_django_model(request):
res = {'data': qset, 'message': '', 'success': True}
return JSONResponse(res)
except ForbiddenModelOrField as e:
logger.error(e)
res = {'data': [], 'message': str(e), 'success': False}
return JSONResponse(res, status=403)
except InvalidRequest as e:
logger.error(e)
res = {'data': [], 'message': str(e), 'success': False}
return JSONResponse(res, status=400)
except Exception as e:
logger.exception(e)
res = {'data': [], 'message': str(e), 'success': False}
return JSONResponse(res, status=500)