Skip to content

Commit

Permalink
Add more descriptive error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
icza committed Aug 21, 2019
1 parent bb4cb5c commit d3e2f48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions repparser/repparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ func parse(dec repdecoder.Decoder, commands, mapData bool) (*rep.Replay, error)
// A replay is a sequence of sections:
for _, s := range Sections {
if err := dec.NewSection(); err != nil {
return nil, err
return nil, fmt.Errorf("Decoder.NewSection() error: %v", err)
}

// Determine section size:
size := s.Size
if size == 0 {
sizeData, err := dec.Section(4)
if err != nil {
return nil, err
return nil, fmt.Errorf("Decoder.Section() error when reading size: %v", err)
}
size = int32(binary.LittleEndian.Uint32(sizeData))
}
Expand All @@ -183,7 +183,7 @@ func parse(dec repdecoder.Decoder, commands, mapData bool) (*rep.Replay, error)
err = ErrNotReplayFile // In case of Replay ID section return special error
}
if err != nil {
return nil, err
return nil, fmt.Errorf("Decoder.Section() error: %v", err)
}

// Need to process?
Expand All @@ -193,7 +193,7 @@ func parse(dec repdecoder.Decoder, commands, mapData bool) (*rep.Replay, error)
default:
// Process section data
if err = s.ParseFunc(data, r); err != nil {
return nil, err
return nil, fmt.Errorf("ParseFunc() error (sectionID: %d): %v", s.ID, err)
}
}

Expand Down

0 comments on commit d3e2f48

Please sign in to comment.