This commit is contained in:
eevee
2024-07-17 01:36:27 +03:00
parent 4e6bf27c44
commit 382c13e9e5
2 changed files with 13 additions and 4 deletions
@@ -53,7 +53,9 @@ struct GeniusLyricsRepository: LyricsRepository {
throw error
}
let rootResponse = try jsonDecoder.decode(GeniusRootResponse.self, from: data!)
guard let rootResponse = try? jsonDecoder.decode(GeniusRootResponse.self, from: data!) else {
throw LyricsError.DecodingError
}
return rootResponse.response
}
@@ -42,8 +42,12 @@ struct PetitLyricsRepository: LyricsRepository {
if let error = error {
throw error
}
guard let response = try? XMLDecoder().decode(PetitResponse.self, from: data!) else {
throw LyricsError.DecodingError
}
return try XMLDecoder().decode(PetitResponse.self, from: data!)
return response
}
//
@@ -77,7 +81,7 @@ struct PetitLyricsRepository: LyricsRepository {
)
guard let song = response.songs.first else {
throw LyricsError.DecodingError
throw LyricsError.NoSuchSong
}
return song
@@ -99,7 +103,10 @@ struct PetitLyricsRepository: LyricsRepository {
switch song.lyricsType {
case .wordsSynced:
let lyrics = try XMLDecoder().decode(PetitLyricsData.self, from: lyricsData)
guard let lyrics = try? XMLDecoder().decode(PetitLyricsData.self, from: lyricsData)
else {
throw LyricsError.DecodingError
}
return LyricsDto(
lines: lyrics.lines.map {