Codebase list golang-github-vbauerster-mpb / 5a9c348
benefit: panic at one place Vladimir Bauer 3 years ago
2 changed file(s) with 15 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
456456 for _, d := range s.pDecorators {
457457 str := d.Decor(stat)
458458 stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str))
459 bufP.WriteString(str)
459 _, err := bufP.WriteString(str)
460 if err != nil {
461 panic(err)
462 }
460463 }
461464 if stat.AvailableWidth < 1 {
462465 trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(bufP.String()), tw, "…"))
474477 for _, d := range s.aDecorators {
475478 str := d.Decor(stat)
476479 stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str))
477 bufA.WriteString(str)
480 _, err := bufA.WriteString(str)
481 if err != nil {
482 panic(err)
483 }
478484 }
479485 if stat.AvailableWidth < 1 {
480486 trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(bufA.String()), tw, "…"))
482488 return io.MultiReader(bufP, bufB, trunc, nlr)
483489 }
484490
485 s.filler.Fill(bufB, stat)
491 err := s.filler.Fill(bufB, stat)
492 if err != nil {
493 panic(err)
494 }
486495
487496 return io.MultiReader(bufP, bufB, bufA, nlr)
488497 }
8787 // BarFillerOnComplete replaces bar's filler with message, on complete event.
8888 func BarFillerOnComplete(message string) BarOption {
8989 return BarFillerMiddleware(func(base BarFiller) BarFiller {
90 return BarFillerFunc(func(w io.Writer, st decor.Statistics) {
90 return BarFillerFunc(func(w io.Writer, st decor.Statistics) error {
9191 if st.Completed {
9292 _, err := io.WriteString(w, message)
93 if err != nil {
94 panic(err)
95 }
96 } else {
97 base.Fill(w, st)
93 return err
9894 }
95 return base.Fill(w, st)
9996 })
10097 })
10198 }