From 704ab0abd218809fc9164985a47f95841ef4a0f9 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Thu, 15 Nov 2018 12:20:52 +0100 Subject: [PATCH] Return error when a file download fails. --- cmd/download.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/download.go b/cmd/download.go index 9ef4988..6047757 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -15,6 +15,7 @@ package cmd import ( "fmt" + "net/http" "os" "path" "regexp" @@ -57,6 +58,9 @@ Loop: case <-t.C: callback(resp) case <-resp.Done: + if resp.HTTPResponse.StatusCode != http.StatusOK { + return fmt.Errorf("error downloading file: %d", resp.HTTPResponse.StatusCode) + } callback(resp) break Loop }