Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aiq committed Feb 16, 2022
1 parent 539edb3 commit d666755
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ func readString(r *bufio.Reader, delim []byte) (string, error) {
if bytes.Equal(buf, delimTail) {
search = false
_, err = r.Read(buf)
builder.Write(buf)
if err != nil {
return builder.String(), err
}
_, err = builder.Write(buf)
if err != nil {
return builder.String(), err
}
}
}
return builder.String(), nil
Expand Down Expand Up @@ -115,7 +121,7 @@ func (my *Reader) readHeader() (Header, error) {
func (my *Reader) readContent() (string, error) {
delim := "//"
if my.expPatt != "" {
delim = "//-" + my.expPatt + "-"
delim = "//" + my.expPatt
}

cnt, err := readString(my.Reader, []byte(delim))
Expand Down

0 comments on commit d666755

Please sign in to comment.