From d3e2f48956de6652525e5f2e4046f4697f826fc4 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Wed, 21 Aug 2019 14:15:16 +0200 Subject: [PATCH] Add more descriptive error messages --- repparser/repparser.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/repparser/repparser.go b/repparser/repparser.go index e4450d5..6da176b 100644 --- a/repparser/repparser.go +++ b/repparser/repparser.go @@ -164,7 +164,7 @@ 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: @@ -172,7 +172,7 @@ func parse(dec repdecoder.Decoder, commands, mapData bool) (*rep.Replay, error) 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)) } @@ -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? @@ -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) } }