Skip to content

Commit

Permalink
Merge pull request metabrainz#2229 from zas/rating_submit_error
Browse files Browse the repository at this point in the history
Display a message when rating submission fails due to server error
  • Loading branch information
zas authored Jun 8, 2023
2 parents de81416 + ea09604 commit 8ed7d43
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion picard/ui/ratingwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ def _getRatingFromPosition(self, position):
rating = self._maximum
return rating

def _submitted(self, document, http, error):
if error:
self.tagger.window.set_statusbar_message(
N_("Failed to submit rating for track '%(track_title)s' due to server error %(error)d"),
{'track_title': self._track.metadata['title'], 'error': error},
echo=None,
)
log.error("Failed to submit rating for %s (server HTTP error %d)", self._track, error)

def _update_track(self):
track = self._track
rating = str(self._rating)
Expand All @@ -103,7 +112,7 @@ def _update_track(self):
if config.setting["submit_ratings"]:
ratings = {("recording", track.id): self._rating}
try:
self.tagger.mb_api.submit_ratings(ratings, None)
self.tagger.mb_api.submit_ratings(ratings, self._submitted)
except ValueError: # This should never happen as self._rating is always an integer
log.error("Failed to submit rating for recording %s", track.id, exc_info=True)

Expand Down

0 comments on commit 8ed7d43

Please sign in to comment.