Skip to content

Commit

Permalink
rework log error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lcduong committed Oct 1, 2024
1 parent 36f09d8 commit 667f89f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/pretalx/orga/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def trigger_public_schedule(
response.raise_for_status() # Raise exception for bad status codes
except requests.RequestException as e:
logger.error(
"Error happen when trigger hide/unhidden schedule to tickets component: %s",
e,
f"Error occurred when triggering hide/unhide schedule for tickets "
f"component. Event: {event_slug}, Organiser: {organiser_slug}. Error: {e}",
)
# Retry the task if an exception occurs (with exponential backoff by default)
try:
Expand Down
12 changes: 9 additions & 3 deletions src/pretalx/orga/views/schedule.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import collections
import datetime as dt
import json
import logging
from contextlib import suppress

import dateutil.parser
from celery.exceptions import TaskError
from csp.decorators import csp_update
from django.conf import settings
from django.contrib import messages
Expand Down Expand Up @@ -52,6 +54,9 @@
)


logger = logging.getLogger(__name__)


@method_decorator(
csp_update(SCRIPT_SRC=SCRIPT_SRC, DEFAULT_SRC=DEFAULT_SRC), name="dispatch"
)
Expand Down Expand Up @@ -250,9 +255,10 @@ def dispatch(self, request, event):
},
ignore_result=True,
)
except Exception:
# Ignore the error if the task fails
pass
except (TaskError, ConnectionError) as e:
logger.warning(f"Task failed: {e}")
except Exception as e:
logger.error(f"Unexpected error in task: {e}")
return redirect(self.request.event.orga_urls.schedule)


Expand Down

0 comments on commit 667f89f

Please sign in to comment.