diff --git a/bar.go b/bar.go index b912208..9ae1121 100644 --- a/bar.go +++ b/bar.go @@ -457,7 +457,10 @@ for _, d := range s.pDecorators { str := d.Decor(stat) stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str)) - bufP.WriteString(str) + _, err := bufP.WriteString(str) + if err != nil { + panic(err) + } } if stat.AvailableWidth < 1 { trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(bufP.String()), tw, "…")) @@ -475,7 +478,10 @@ for _, d := range s.aDecorators { str := d.Decor(stat) stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str)) - bufA.WriteString(str) + _, err := bufA.WriteString(str) + if err != nil { + panic(err) + } } if stat.AvailableWidth < 1 { trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(bufA.String()), tw, "…")) @@ -483,7 +489,10 @@ return io.MultiReader(bufP, bufB, trunc, nlr) } - s.filler.Fill(bufB, stat) + err := s.filler.Fill(bufB, stat) + if err != nil { + panic(err) + } return io.MultiReader(bufP, bufB, bufA, nlr) } diff --git a/bar_option.go b/bar_option.go index 2a6b637..bf3d5d5 100644 --- a/bar_option.go +++ b/bar_option.go @@ -88,15 +88,12 @@ // BarFillerOnComplete replaces bar's filler with message, on complete event. func BarFillerOnComplete(message string) BarOption { return BarFillerMiddleware(func(base BarFiller) BarFiller { - return BarFillerFunc(func(w io.Writer, st decor.Statistics) { + return BarFillerFunc(func(w io.Writer, st decor.Statistics) error { if st.Completed { _, err := io.WriteString(w, message) - if err != nil { - panic(err) - } - } else { - base.Fill(w, st) + return err } + return base.Fill(w, st) }) }) }