Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add informative errors for the unmarshaling processes in the MavenPackageHandler #588

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packagehandlers/mavenpackagehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (mph *MavenPackageHandler) fillDependenciesMap(pomPath string) error {
func getMavenDependencies(pomXmlContent []byte) (result []gavCoordinate, err error) {
var dependencies mavenDependency
if err = xml.Unmarshal(pomXmlContent, &dependencies); err != nil {
err = fmt.Errorf("failed to unmarshal the current pom.xml:\n%s, error received:\n%w"+string(pomXmlContent), err)
return
}
result = append(result, dependencies.collectMavenDependencies(false)...)
Expand Down Expand Up @@ -199,6 +200,7 @@ func (mph *MavenPackageHandler) getProjectPoms() (err error) {
// Escape backslashes in the pomPath field, to fix windows backslash parsing issues
escapedContent := strings.ReplaceAll(jsonContent, `\`, `\\`)
if err = json.Unmarshal([]byte(escapedContent), &pp); err != nil {
err = fmt.Errorf("failed to unmarshal the maven-dep-tree output. Full maven-dep-tree output:\n%s\nCurrent line:\n%s\nError details:\n%w", string(depTreeOutput), escapedContent, err)
return
}
mph.pomPaths = append(mph.pomPaths, pp)
Expand Down
Loading