Skip to content

Commit

Permalink
Return error when a file download fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Nov 15, 2018
1 parent 5af35c3 commit 704ab0a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package cmd

import (
"fmt"
"net/http"
"os"
"path"
"regexp"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 704ab0a

Please sign in to comment.