From d666755bcac42300934e983c33810a3f4c55a01f Mon Sep 17 00:00:00 2001 From: aiq Date: Wed, 16 Feb 2022 21:10:45 +0100 Subject: [PATCH] better error handling --- Reader.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Reader.go b/Reader.go index 83babc5..6dbacba 100644 --- a/Reader.go +++ b/Reader.go @@ -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 @@ -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))