Skip to content

Commit

Permalink
refactor: handle error
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed Jan 24, 2024
1 parent ca6bbaa commit 365ac8d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/java/pom/pom.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (props *properties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
if err == io.EOF {
break
} else if err != nil {
return err
return xerrors.Errorf("XML decode error: %w", err)
}

(*props)[p.XMLName.Local] = p.Value
Expand All @@ -311,11 +311,10 @@ func (props *properties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
func (deps *pomDependencies) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error {
for {
token, err := d.Token()
if err != nil {
if err == io.EOF {
break // End of file, exit loop
}
return xerrors.Errorf("Error decoding XML: %w")
if err == io.EOF {
break
} else if err != nil {
return xerrors.Errorf("XML decode error: %w", err)
}

switch t := token.(type) {
Expand All @@ -324,13 +323,13 @@ func (deps *pomDependencies) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) er
var dep pomDependency
dep.StartLine, _ = d.InputPos() // <dependency> tag starts

// Decode <dependency>
// Decode the <dependency> element
err = d.DecodeElement(&dep, &t)
if err != nil {
return xerrors.Errorf("Error decoding dependency: %w")
}

dep.EndLine, _ = d.InputPos()
dep.EndLine, _ = d.InputPos() // <dependency> tag ends

deps.Dependency = append(deps.Dependency, dep)
}
Expand Down

0 comments on commit 365ac8d

Please sign in to comment.