Skip to content

Commit

Permalink
Improve error reporting in mgmt cmds (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula authored Apr 22, 2024
1 parent 5bf05fc commit 2b2cdba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import traceback

from django.core.management.base import BaseCommand
from django.utils import timezone

Expand All @@ -17,10 +19,10 @@ def handle(self, *args, **kwargs):
self.stdout.write(
self.style.SUCCESS("Successfully marked all stale invites as expired!")
)
except Exception as e:
except Exception:
self.stdout.write(
self.style.ERROR(
"An error was encountered while expiring stale membership invites!"
)
)
self.stdout.write(str(e))
self.stdout.write(self.style.ERROR(traceback.format_exc()))
2 changes: 2 additions & 0 deletions backend/clubs/management/commands/find_broken_images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import traceback

import requests
from django.conf import settings
Expand Down Expand Up @@ -41,6 +42,7 @@ def handle(self, *args, **kwargs):
"{} has broken image {}".format(club.code, club.image.url)
)
)
self.stdout.write(self.style.ERROR(traceback.format_exc()))
if not self.dry_run:
club.image.delete(save=True)
broken_list.append(
Expand Down
9 changes: 5 additions & 4 deletions backend/clubs/management/commands/update_club_counts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import traceback

from django.core.management.base import BaseCommand
from django.db.models import Count, Q

Expand Down Expand Up @@ -26,11 +28,10 @@ def handle(self, *args, **kwargs):
"Successfully updated all club favorite and membership counts!"
)
)
except Exception as e:
except Exception:
self.stdout.write(
self.style.ERROR(
"An error was encountered while updating"
+ "club favorite and membership counts!"
"Error while updating club favorite & membership counts!"
)
)
self.stdout.write(e)
self.stdout.write(self.style.ERROR(traceback.format_exc()))

0 comments on commit 2b2cdba

Please sign in to comment.