Skip to content

Commit

Permalink
refactor(java): add error/statusCode for logs when we can't get pom.x…
Browse files Browse the repository at this point in the history
…ml/maven-metadata.xml from remote repo (#7451)
  • Loading branch information
DmitriyLewen authored Sep 6, 2024
1 parent 4926da7 commit 412fb76
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 412fb76

Please sign in to comment.