check error

This commit is contained in:
Michael Zhang 2021-07-22 01:34:33 -05:00
parent 004acffce1
commit 8db272d46c
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

View file

@ -27,9 +27,14 @@ func (api *Osuapi) SearchBeatmaps(rankStatus string) (beatmapSearch BeatmapSearc
func (api *Osuapi) DownloadSingleBeatmap(beatmapId int, path string) (err error) { func (api *Osuapi) DownloadSingleBeatmap(beatmapId int, path string) (err error) {
url := fmt.Sprintf("https://osu.ppy.sh/osu/%d", beatmapId) url := fmt.Sprintf("https://osu.ppy.sh/osu/%d", beatmapId)
resp, err := api.httpClient.Get(url) resp, err := api.httpClient.Get(url)
if err != nil {
err = errors.Wrap(err, "could not fetch beatmap")
return
}
file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0644) file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0644)
if err != nil { if err != nil {
err = errors.Wrap(err, "could not open file for downloading beatmap")
return return
} }