Catch ValueError at the end of a radio

This commit is contained in:
petitminion 2022-03-16 12:54:35 +00:00 committed by Georg Krause
parent 8e2d686386
commit 5b7a28684a
4 changed files with 14 additions and 2 deletions

View File

@ -137,7 +137,12 @@ class RadioSessionTrackViewSet(mixins.CreateModelMixin, viewsets.GenericViewSet)
)
except AssertionError:
return Response(status=status.HTTP_403_FORBIDDEN)
session.radio.pick()
try:
session.radio.pick()
except ValueError:
return Response(
"Radio doesn't have more candidates", status=status.HTTP_404_NOT_FOUND
)
session_track = session.session_tracks.all().latest("id")
# self.perform_create(serializer)
# dirty override here, since we use a different serializer for creation and detail

View File

@ -0,0 +1 @@
Catch ValueError on radio end (#1596)

View File

@ -99,6 +99,11 @@ axios.interceptors.response.use(function (response) {
}
if (error.response.status === 404) {
error.backendErrors.push('Resource not found')
const message = error.response.data
store.commit('ui/addMessage', {
content: message,
class: 'error'
})
} else if (error.response.status === 403) {
error.backendErrors.push('Permission denied')
} else if (error.response.status === 429) {

View File

@ -97,8 +97,9 @@ export default {
dispatch('queue/last', null, { root: true })
})
}
}, (response) => {
}, () => {
logger.default.error('Error while adding track to queue from radio')
commit('reset')
})
}
}