replace exception logging with exception level method

This commit is contained in:
aj 2020-07-01 11:02:49 +01:00
parent b35b4c2b8c
commit fd2f0b288c
4 changed files with 24 additions and 24 deletions

View File

@ -27,10 +27,10 @@ def get_chart_of_spotify_tracks(spotnet: SpotNetwork,
spotify_chart.append(spotify_search[0])
else:
logger.debug('no search tracks returned')
except SpotifyNetworkException as e:
logger.error(f'error during search function - {e}')
except SpotifyNetworkException:
logger.exception(f'error during search function')
return spotify_chart
except LastFMNetworkException as e:
logger.error(f'error during chart retrieval function - {e}')
except LastFMNetworkException:
logger.exception(f'error during chart retrieval function')
return []

View File

@ -38,5 +38,5 @@ class ChartSource(TrackSource):
fmnet=self.fmnet,
period=params.chart_range,
limit=params.limit)
except LastFMNetworkException as e:
logger.error(f'error occured during chart retrieval - {e}')
except LastFMNetworkException:
logger.exception(f'error occured during chart retrieval')

View File

@ -45,8 +45,8 @@ class Counter:
if playlist.has_tracks() is False:
try:
playlist.tracks = self.spotnet.get_playlist_tracks(uri=playlist.uri)
except SpotifyNetworkException as e:
logger.error(f'error occured during playlist track retrieval - {e}')
except SpotifyNetworkException:
logger.exception(f'error occured during playlist track retrieval')
return 0
if uri is not None:
@ -54,8 +54,8 @@ class Counter:
raise ValueError('uri not a playlist')
try:
playlist = self.spotnet.get_playlist(uri=uri, tracks=True)
except SpotifyNetworkException as e:
logger.error(f'error occured during playlist retrieval - {e}')
except SpotifyNetworkException:
logger.exception(f'error occured during playlist retrieval')
return 0
scrobble_count = 0
@ -92,8 +92,8 @@ class Counter:
raise ValueError('uri not a track')
try:
track = self.spotnet.get_track(uri=uri)
except SpotifyNetworkException as e:
logger.error(f'error occured during track retrieval - {e}')
except SpotifyNetworkException:
logger.exception(f'error occured during track retrieval')
return 0
try:
@ -105,8 +105,8 @@ class Counter:
else:
logger.error(f'no track returned for {track}')
return 0
except LastFMNetworkException as e:
logger.error(f'error occured during track retrieval - {e}')
except LastFMNetworkException:
logger.exception(f'error occured during track retrieval')
return 0
def count_album(self, username: str = None, uri: Uri = None, album: SimplifiedAlbum = None) -> int:
@ -119,8 +119,8 @@ class Counter:
raise ValueError('uri not an album')
try:
album = self.spotnet.get_album(uri=uri)
except SpotifyNetworkException as e:
logger.error(f'error occured during album retrieval - {e}')
except SpotifyNetworkException:
logger.exception(f'error occured during album retrieval')
return 0
try:
@ -132,8 +132,8 @@ class Counter:
else:
logger.error(f'no track returned for {album}')
return 0
except LastFMNetworkException as e:
logger.error(f'error occured during album retrieval - {e}')
except LastFMNetworkException:
logger.exception(f'error occured during album retrieval')
return 0
def count_artist(self, username: str = None, uri: Uri = None, artist: SimplifiedArtist = None) -> int:
@ -146,8 +146,8 @@ class Counter:
raise ValueError('uri not an artist')
try:
artist = self.spotnet.get_artist(uri=uri)
except SpotifyNetworkException as e:
logger.error(f'error occured during artist retrieval - {e}')
except SpotifyNetworkException:
logger.exception(f'error occured during artist retrieval')
return 0
try:
@ -157,6 +157,6 @@ class Counter:
else:
logger.error(f'no track returned for {artist}')
return 0
except LastFMNetworkException as e:
logger.error(f'error occured during artist retrieval - {e}')
except LastFMNetworkException:
logger.exception(f'error occured during artist retrieval')
return 0

View File

@ -31,8 +31,8 @@ class Stats(Cmd):
try:
user_total = self.fmnet.get_user_scrobble_count()
except LastFMNetworkException as e:
logger.error(f'error occured during scrobble count retrieval - {e}')
except LastFMNetworkException:
logger.exception(f'error occured during scrobble count retrieval')
user_total = 0
total = 0