Skip to content

Commit

Permalink
some
Browse files Browse the repository at this point in the history
  • Loading branch information
whoeevee authored and Dark-Matter7232 committed Jul 19, 2024
1 parent abbb28c commit cc74771
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

//
Expand Down Expand Up @@ -77,7 +81,7 @@ struct PetitLyricsRepository: LyricsRepository {
)

guard let song = response.songs.first else {
throw LyricsError.DecodingError
throw LyricsError.NoSuchSong
}

return song
Expand All @@ -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 {
Expand Down

0 comments on commit cc74771

Please sign in to comment.