-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
Improve Error Handling and Retry Mechanism in Track Fetching Logic
Description:
There is a need to improve the error handling and retry mechanism in the track-fetching process, especially for external sources like Spotify, Deezer, and SoundCloud. The current implementation lacks proper exception handling and user feedback in case of failures, making it harder to debug issues and provide a better user experience.
Improvements:
-
Error Handling:
- Each external source (Spotify, Deezer, SoundCloud) should have its own try-except block to catch and log exceptions separately.
- If any source fails, return a user-friendly error message, like:
"Failed to retrieve recommendations from Spotify." - Print detailed error tracebacks in logs for easier debugging.
-
Retry Mechanism:
- Implement a retry mechanism for Spotify API calls, which should attempt to fetch tracks up to 3 times before returning an error message.
- Add a delay (
await asyncio.sleep(5)) between retries to avoid overloading the system in case of temporary failures.
-
Track Creation Logic:
- Use a helper function (
create_partial_track()) to handle the creation of track objects for each source, reducing duplication of code. - Ensure all external sources handle track creation in a standardized way.
- Use a helper function (
-
Fallback Messages:
- If no tracks are found for a given query, return a message like
"No tracks found for the given query."
- If no tracks are found for a given query, return a message like
Steps to Reproduce:
- Use a track search with external sources (Spotify, Deezer, SoundCloud).
- If an error occurs, observe that the bot currently doesn't handle the errors well and doesn't provide a user-friendly message.
Expected Behavior:
- The bot should log all errors properly with tracebacks.
- It should retry the operation for external sources like Spotify and Deezer up to 3 times.
- If no tracks are found, the bot should return a clear message indicating no tracks were found.
Additional Context:
This improvement will make the bot more robust and user-friendly, as well as improve debugging when external APIs fail.
Metadata
Metadata
Assignees
Labels
No labels