Skip to content

Commit

Permalink
refactor(pom): add err/status code for failed to fetch logs
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Sep 6, 2024
1 parent 4926da7 commit 60d0b0c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/dependency/parser/java/pom/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,11 @@ func (p *Parser) fetchPomFileNameFromMavenMetadata(repo string, paths []string)

client := &http.Client{}
resp, err := client.Do(req)
if err != nil || resp.StatusCode != http.StatusOK {
p.logger.Debug("Failed to fetch", log.String("url", req.URL.String()))
if err != nil {
p.logger.Debug("Failed to fetch", log.String("url", req.URL.String()), log.Err(err))
return "", nil
} else if resp.StatusCode != http.StatusOK {
p.logger.Debug("Failed to fetch", log.String("url", req.URL.String()), log.Int("statusCode", resp.StatusCode))
return "", nil
}
defer resp.Body.Close()
Expand Down Expand Up @@ -745,8 +748,11 @@ func (p *Parser) fetchPOMFromRemoteRepository(repo string, paths []string) (*pom

client := &http.Client{}
resp, err := client.Do(req)
if err != nil || resp.StatusCode != http.StatusOK {
p.logger.Debug("Failed to fetch", log.String("url", req.URL.String()))
if err != nil {
p.logger.Debug("Failed to fetch", log.String("url", req.URL.String()), log.Err(err))
return nil, nil
} else if resp.StatusCode != http.StatusOK {
p.logger.Debug("Failed to fetch", log.String("url", req.URL.String()), log.Int("statusCode", resp.StatusCode))
return nil, nil
}
defer resp.Body.Close()
Expand Down

0 comments on commit 60d0b0c

Please sign in to comment.