Skip to content

Commit

Permalink
fix: Handling Auth Error (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak Sharma authored Apr 27, 2021
1 parent 4bfa169 commit 1438e2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions analyses/stackanalyses/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ func (mc *Controller) validatePostResponse(apiResponse *http.Response) (*driver.
log.Debug().Msgf("Executing validatePostResponse.")
var body driver.PostResponseType
err := json.NewDecoder(apiResponse.Body).Decode(&body)

// In Case of Authentication Failure, json is not return from API, Need to catch before decoding.
if apiResponse.StatusCode == http.StatusForbidden {
log.Debug().Msgf("Status from Server: %d", apiResponse.StatusCode)
log.Error().Msgf("Stack Analyses Post Request Failed. Please check auth token and try again.")
return nil, fmt.Errorf("invalid authentication token")
}

if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion gomanifest/generator/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ func GetDeps(cmd GoList) (map[string]DepPackage, error) {
if err := cmd.Wait(); err != nil {
return nil, fmt.Errorf("%v: `go list` failed, use `go mod tidy` to known more", err)
}
log.Info().Msgf("Total packages: \t\t%d", len(depPackagesMap))
log.Debug().Msgf("Total packages: \t\t%d", len(depPackagesMap))
return depPackagesMap, nil
}
4 changes: 2 additions & 2 deletions gomanifest/generator/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func BuildManifest(depPackages *map[string]DepPackage) Manifest {
}
}
}
log.Info().Msgf("Source code imports: \t%d", len(sourceImports))
log.Info().Msgf("Direct dependencies: \t%d", len(manifest.Packages))
log.Debug().Msgf("Source code imports: \t%d", len(sourceImports))
log.Debug().Msgf("Direct dependencies: \t%d", len(manifest.Packages))

return manifest
}

0 comments on commit 1438e2e

Please sign in to comment.