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

Commit

Permalink
add logging in case of unsuccessful operation (#25)
Browse files Browse the repository at this point in the history
display complete traceback if there is an Internal server error (for status code 500)
otherwise log the error statement only.

Signed-off-by: Priyank Singh <priyanksi@vmware.com>
  • Loading branch information
preyunk authored Apr 28, 2023
1 parent 0cb677d commit 30b2ddc
Showing 1 changed file with 4 additions and 1 deletion.
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)

0 comments on commit 30b2ddc

Please sign in to comment.