care
care copied to clipboard
ABDM: Log the errors instead of sending them as a response
refer: https://github.com/coronasafe/care/pull/1814
Can I take this up?
So as I understand the issue, We have to log the error response instead of sending them as response in places like these in the abdm API?:
try:
AbdmGateway().init(data["resp"]["requestId"])
except Exception as e:
return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST)
Questions:
- What should be sent instead of the
e
object to the client instead? - This is how we should log instead right?
logger = logging.getLogger(__nane__)
def post(self, request, *args, **kwargs):
data = request.data
try:
AbdmGateway().init(data["resp"]["requestId"])
except Exception as e:
logger.warning(f"Error while initialising ABDM Gateway: {e}", exc_info=True)
return Response({ "error": "Something went wrong." }, status=status.HTTP_400_BAD_REQUEST)
return Response({}, status=status.HTTP_202_ACCEPTED)
Yes, that works, while logging, just use the function name or the endpoint, that should be enough.
@khavinshankar Can you take a look at #1821 and see if it looks good?