From 3901a2825b6ff41e425b5691b3c33c1f99a45713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Thu, 12 Aug 2021 17:27:43 +0300 Subject: [PATCH] Replace str(exc) with exc.message to make CodeQL happy --- hc/api/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hc/api/views.py b/hc/api/views.py index d09b6848..03ebb6ef 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -25,7 +25,8 @@ from hc.lib.badges import check_signature, get_badge_svg class BadChannelException(Exception): - pass + def __init__(self, message): + self.message = message @csrf_exempt @@ -195,7 +196,7 @@ def create_check(request): try: _update(check, request.json) except BadChannelException as e: - return JsonResponse({"error": str(e)}, status=400) + return JsonResponse({"error": e.message}, status=400) return JsonResponse(check.to_dict(), status=201 if created else 200) @@ -249,7 +250,7 @@ def update_check(request, code): try: _update(check, request.json) except BadChannelException as e: - return JsonResponse({"error": str(e)}, status=400) + return JsonResponse({"error": e.message}, status=400) return JsonResponse(check.to_dict())