| skipped 2 lines |
3 | 3 | | import ( |
4 | 4 | | "bufio" |
5 | 5 | | "encoding/json" |
6 | | - | "errors" |
7 | 6 | | "flag" |
8 | 7 | | "fmt" |
9 | 8 | | log "github.com/sirupsen/logrus" |
| skipped 47 lines |
57 | 56 | | func getSnapshots(c http.Client, url string) ([][]string, error) { |
58 | 57 | | req, err := http.NewRequest("GET", fmt.Sprintf(wbSnapshotApiURL, url), nil) |
59 | 58 | | if err != nil { |
60 | | - | return [][]string{}, fmt.Errorf("getSnapshots: failed to generate request waybackmachine api: %w", err) |
| 59 | + | return [][]string{}, fmt.Errorf("getSnapshots: failed to generate request waybackmachine api: %w url: %s", err, url) |
61 | 60 | | } |
62 | 61 | | |
63 | 62 | | rsp, err := c.Do(req) |
64 | 63 | | if err != nil { |
65 | | - | return [][]string{}, fmt.Errorf("getSnapshots: failed to send request waybackmachine api: %w", err) |
| 64 | + | return [][]string{}, fmt.Errorf("getSnapshots: failed to send request waybackmachine api: %w url: %s", err, url) |
66 | 65 | | } |
67 | 66 | | defer rsp.Body.Close() |
68 | 67 | | |
| skipped 2 lines |
71 | 70 | | |
72 | 71 | | err = dec.Decode(&r) |
73 | 72 | | if err != nil { |
74 | | - | return [][]string{}, fmt.Errorf("getSnapshots: error while decoding response %w", err) |
| 73 | + | return [][]string{}, fmt.Errorf("getSnapshots: error while decoding response %w url: %s", err, url) |
75 | 74 | | } |
76 | 75 | | |
77 | 76 | | if len(r) < 1 { |
78 | | - | return [][]string{}, errors.New("getSnapshots: no results found for this url") |
| 77 | + | return [][]string{}, fmt.Errorf("getSnapshots: no results found for this url: %s", url) |
79 | 78 | | } |
80 | 79 | | |
81 | 80 | | return r[1:], nil |
| skipped 2 lines |
84 | 83 | | func getSnapshotContent(c http.Client, ts, url string) (io.ReadCloser, error) { |
85 | 84 | | req, err := http.NewRequest("GET", fmt.Sprintf(wbFileURL, ts, url), nil) |
86 | 85 | | if err != nil { |
87 | | - | return nil, fmt.Errorf("getSnapshotContent: failed to generate request waybackmachine api: %w", err) |
| 86 | + | return nil, fmt.Errorf("getSnapshotContent: failed to generate request waybackmachine api: %w url: %s", err, url) |
88 | 87 | | } |
89 | 88 | | req.Header.Add("Accept-Encoding", "plain") |
90 | 89 | | |
91 | 90 | | rsp, err := c.Do(req) |
92 | 91 | | if err != nil { |
93 | | - | return nil, fmt.Errorf("getSnapshotContent: failed to send request waybackmachine api: %w", err) |
| 92 | + | return nil, fmt.Errorf("getSnapshotContent: failed to send request waybackmachine api: %w url: %s", err, url) |
94 | 93 | | } |
95 | | - | defer rsp.Body.Close() |
96 | 94 | | |
97 | 95 | | return rsp.Body, nil |
98 | 96 | | } |
| skipped 1 lines |