From 0e2c56bf5f3aebef5b96354b873c1cf84e495199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Fri, 17 Mar 2023 17:37:08 +0100 Subject: [PATCH] fix(api): properly handle errors in crawler loop --- src/sources/spotify/spotify.service.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/sources/spotify/spotify.service.ts b/src/sources/spotify/spotify.service.ts index b83dda2..ab0ae3e 100644 --- a/src/sources/spotify/spotify.service.ts +++ b/src/sources/spotify/spotify.service.ts @@ -99,17 +99,16 @@ export class SpotifyService { { userId: user.id }, `Refreshing access token failed for user "${user.id}": ${errFromAuth}` ); + throw errFromAuth; } - } else { - // TODO sent to sentry - this.logger.error( - `Unexpected error while fetching recently played tracks: ${err}` - ); + + return; } - // Makes no sense to keep processing the (inexistent) data but if we throw - // the error the fetch loop will not process other users. - return; + this.logger.error( + `Unexpected error while fetching recently played tracks: ${err}` + ); + throw err; } if (playHistory.length === 0) {