From 2286a6ebef94a05e89b312ea053517bd0937abdb Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 18 Aug 2020 12:54:20 +0200 Subject: [PATCH] cmd/stcrashreceiver: Don't crash on nil err --- cmd/stcrashreceiver/sourcecodeloader.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/stcrashreceiver/sourcecodeloader.go b/cmd/stcrashreceiver/sourcecodeloader.go index ee3e91ffb..1da310d3c 100644 --- a/cmd/stcrashreceiver/sourcecodeloader.go +++ b/cmd/stcrashreceiver/sourcecodeloader.go @@ -72,8 +72,12 @@ func (l *githubSourceCodeLoader) Load(filename string, line, context int) ([][]b url := urlPrefix + l.version + filename[idx:] resp, err := l.client.Get(url) - if err != nil || resp.StatusCode != http.StatusOK { - fmt.Println("Loading source:", err.Error()) + if err != nil { + fmt.Println("Loading source:", err) + return nil, 0 + } + if resp.StatusCode != http.StatusOK { + fmt.Println("Loading source:", resp.Status) return nil, 0 } data, err := ioutil.ReadAll(resp.Body)