Skip to content

Commit

Permalink
Merge pull request #74 from freezingsaddles/rework-exceptions
Browse files Browse the repository at this point in the history
Rework exceptions and logging a bit
  • Loading branch information
obscurerichard authored Jan 1, 2025
2 parents 582e8bd + 7a773f5 commit 9a9058e
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions freezing/sync/data/athlete.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
from datetime import datetime

import arrow
from freezing.model import meta
from freezing.model.orm import (
Athlete,
Ride,
RideEffort,
RideError,
RideGeo,
RidePhoto,
Team,
)
from geoalchemy2.elements import WKTElement
from sqlalchemy import and_
from sqlalchemy.orm import joinedload
from stravalib import model as sm
from stravalib import unithelper
from stravalib.exc import Fault

from freezing.sync.config import config
from freezing.sync.exc import (
CommandError,
DataEntryError,
MultipleTeamsError,
NoTeamsError,
)
from freezing.sync.utils.cache import CachingActivityFetcher

from . import BaseSync, StravaClientForAthlete


Expand Down Expand Up @@ -58,8 +43,12 @@ def sync_athletes(self, max_records: int = None):
self.register_athlete(strava_athlete, athlete.access_token)
if not self.all_done():
self.register_athlete_team(strava_athlete, athlete)
except:
self.logger.warning(
except NoTeamsError as ex:
self.logger.info(f'Athlete "{athlete}" is not on a registered team: {ex}')
except MultipleTeamsError as ex:
self.logger.info(f'Athlete "{athlete}" is on multiple competition teams: {ex}')
except Exception:
self.logger.exception(
"Error registering athlete {0}".format(athlete), exc_info=True
)

Expand Down Expand Up @@ -109,7 +98,7 @@ def unambiguous_display_name() -> str:
f"Athlete '{athlete_name}' was renamed '{athlete.name}'"
)
athlete.display_name = unambiguous_display_name()
except:
except Exception:
self.logger.exception(
f"Athlete name disambiguation error for {strava_athlete.id}",
exc_info=True,
Expand Down

0 comments on commit 9a9058e

Please sign in to comment.