Skip to content

Commit a651377

Browse files
committed
fix: throw an error when there are no matching lyrics instead of returning an empty lyrics object
1 parent d6f5a4c commit a651377

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/LyricsService/Provider/Services/Musixmatch.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ extension LyricsProviders.Musixmatch: _LyricsProvider {
112112

113113
public func fetch(with token: LyricsToken) async throws -> Lyrics {
114114
// Check if synced lyrics are available
115-
if token.value.hasSubtitles == 0 || token.value.instrumental == 1 {
116-
return Lyrics(lines: [], idTags: [:])
115+
if token.value.hasSubtitles == 0 {
116+
throw LyricsProviderError.processingFailed(reason: "Lyrics not found")
117+
}
118+
if token.value.instrumental == 1 {
119+
throw LyricsProviderError.processingFailed(reason: "Instrumental track")
117120
}
118121

119122
// Build URL with query items
@@ -167,7 +170,7 @@ extension LyricsProviders.Musixmatch: _LyricsProvider {
167170
.subtitleBody,
168171
let track = body.matcherTrackGet?.message.body.track
169172
else {
170-
return Lyrics(lines: [], idTags: [:])
173+
throw LyricsProviderError.processingFailed(reason: "Lyrics not found")
171174
}
172175

173176
let lyrics = try parseLyrics(subtitle, with: track)

0 commit comments

Comments
 (0)