From 0d264838a987bd702d3ad0459822a70fcd608ac1 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Sat, 22 Apr 2023 01:04:07 +0530 Subject: [PATCH] remove: print exception instead use capture to log it (#926) --- apiserver/plane/api/views/base.py | 4 ++-- apiserver/plane/api/views/importer.py | 2 +- apiserver/plane/api/views/issue.py | 2 +- apiserver/plane/api/views/oauth.py | 7 +++---- apiserver/plane/api/views/page.py | 2 +- apiserver/plane/api/views/search.py | 2 +- apiserver/plane/api/views/workspace.py | 4 +--- apiserver/plane/bgtasks/issue_activites_task.py | 1 - apiserver/plane/bgtasks/magic_link_code_task.py | 1 - apiserver/plane/bgtasks/project_invitation_task.py | 1 - 10 files changed, 10 insertions(+), 16 deletions(-) diff --git a/apiserver/plane/api/views/base.py b/apiserver/plane/api/views/base.py index a4b9ac584..3c260e03b 100644 --- a/apiserver/plane/api/views/base.py +++ b/apiserver/plane/api/views/base.py @@ -10,7 +10,7 @@ from rest_framework.views import APIView from rest_framework.filters import SearchFilter from rest_framework.permissions import IsAuthenticated from rest_framework.exceptions import NotFound - +from sentry_sdk import capture_exception from django_filters.rest_framework import DjangoFilterBackend # Module imports @@ -39,7 +39,7 @@ class BaseViewSet(ModelViewSet, BasePaginator): try: return self.model.objects.all() except Exception as e: - print(e) + capture_exception(e) raise APIException("Please check the view", status.HTTP_400_BAD_REQUEST) def dispatch(self, request, *args, **kwargs): diff --git a/apiserver/plane/api/views/importer.py b/apiserver/plane/api/views/importer.py index a51af9c22..a1d485d89 100644 --- a/apiserver/plane/api/views/importer.py +++ b/apiserver/plane/api/views/importer.py @@ -104,7 +104,7 @@ class ServiceIssueImportSummaryEndpoint(BaseAPIView): status=status.HTTP_400_BAD_REQUEST, ) except Exception as e: - print(e) + capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, status=status.HTTP_400_BAD_REQUEST, diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index c0f54bcdb..987677bb2 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -618,7 +618,7 @@ class SubIssuesEndpoint(BaseAPIView): status=status.HTTP_200_OK, ) except Exception as e: - print(e) + capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, status=status.HTTP_400_BAD_REQUEST, diff --git a/apiserver/plane/api/views/oauth.py b/apiserver/plane/api/views/oauth.py index 650a8cc96..184cba951 100644 --- a/apiserver/plane/api/views/oauth.py +++ b/apiserver/plane/api/views/oauth.py @@ -14,7 +14,7 @@ from rest_framework.permissions import AllowAny from rest_framework.views import APIView from rest_framework_simplejwt.tokens import RefreshToken from rest_framework import status - +from sentry_sdk import capture_exception # sso authentication from google.oauth2 import id_token from google.auth.transport import requests as google_auth_request @@ -48,7 +48,7 @@ def validate_google_token(token, client_id): } return data except Exception as e: - print(e) + capture_exception(e) raise exceptions.AuthenticationFailed("Error with Google connection.") @@ -305,8 +305,7 @@ class OauthEndpoint(BaseAPIView): ) return Response(data, status=status.HTTP_201_CREATED) except Exception as e: - print(e) - + capture_exception(e) return Response( { "error": "Something went wrong. Please try again later or contact the support team." diff --git a/apiserver/plane/api/views/page.py b/apiserver/plane/api/views/page.py index b3f5b2dd5..0943a6ffe 100644 --- a/apiserver/plane/api/views/page.py +++ b/apiserver/plane/api/views/page.py @@ -344,7 +344,7 @@ class RecentPagesEndpoint(BaseAPIView): status=status.HTTP_200_OK, ) except Exception as e: - print(e) + capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, status=status.HTTP_400_BAD_REQUEST, diff --git a/apiserver/plane/api/views/search.py b/apiserver/plane/api/views/search.py index f73a3c9c8..823a1fcc8 100644 --- a/apiserver/plane/api/views/search.py +++ b/apiserver/plane/api/views/search.py @@ -195,7 +195,7 @@ class GlobalSearchEndpoint(BaseAPIView): return Response({"results": results}, status=status.HTTP_200_OK) except Exception as e: - print(e) + capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, status=status.HTTP_400_BAD_REQUEST, diff --git a/apiserver/plane/api/views/workspace.py b/apiserver/plane/api/views/workspace.py index 915ade2fc..8a2791e3b 100644 --- a/apiserver/plane/api/views/workspace.py +++ b/apiserver/plane/api/views/workspace.py @@ -145,7 +145,6 @@ class UserWorkSpacesEndpoint(BaseAPIView): return Response(serializer.data, status=status.HTTP_200_OK) except Exception as e: - print(e) capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, @@ -333,7 +332,6 @@ class JoinWorkspaceEndpoint(BaseAPIView): status=status.HTTP_404_NOT_FOUND, ) except Exception as e: - print(e) capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, @@ -780,7 +778,7 @@ class WorkspaceThemeViewSet(BaseViewSet): status=status.HTTP_400_BAD_REQUEST, ) except Exception as e: - print(e) + capture_exception(e) return Response( {"error": "Something went wrong please try again later"}, status=status.HTTP_400_BAD_REQUEST, diff --git a/apiserver/plane/bgtasks/issue_activites_task.py b/apiserver/plane/bgtasks/issue_activites_task.py index c4fde9646..c513c3107 100644 --- a/apiserver/plane/bgtasks/issue_activites_task.py +++ b/apiserver/plane/bgtasks/issue_activites_task.py @@ -947,6 +947,5 @@ def issue_activity( ) return except Exception as e: - print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/magic_link_code_task.py b/apiserver/plane/bgtasks/magic_link_code_task.py index ea97b0fb8..00a4e6807 100644 --- a/apiserver/plane/bgtasks/magic_link_code_task.py +++ b/apiserver/plane/bgtasks/magic_link_code_task.py @@ -30,6 +30,5 @@ def magic_link(email, key, token, current_site): msg.send() return except Exception as e: - print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/project_invitation_task.py b/apiserver/plane/bgtasks/project_invitation_task.py index 1c3597120..2015ffe5e 100644 --- a/apiserver/plane/bgtasks/project_invitation_task.py +++ b/apiserver/plane/bgtasks/project_invitation_task.py @@ -50,6 +50,5 @@ def project_invitation(email, project_id, token, current_site): except (Project.DoesNotExist, ProjectMemberInvite.DoesNotExist) as e: return except Exception as e: - print(e) capture_exception(e) return