-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
enhancementNew feature or requestNew feature or request
Description
hello! I encountered an issue using this lib, looked for the source of it, and found out something that might be a wrong decision.
here's what happened to me:
- I tried to print a box with this code:
box.New(box.Config{
Py: 0,
Px: 5,
ContentAlign: "Center",
Type: "Double",
TitlePos: "Inside",
AllowWrapping: true,
}).Println(title, msg)- I started my app in a container started by docker-compose.
- my app fataled with the message
inappropriate ioctl for device - I looked in the code and found out that if I'm setting
AllowWrappingto true and an error is returned fromterm.GetSize,the code calls to log.Fatal:
// Allow Wrapping according to the user
if b.AllowWrapping {
// If limit not provided then use 2*TermWidth/3 as limit else
// use the one provided
if b.WrappingLimit != 0 {
lines = wrap.String(lines, b.WrappingLimit)
} else {
width, _, err := term.GetSize(int(os.Stdout.Fd()))
if err != nil {
log.Fatal(err)
}
lines = wrap.String(lines, 2*width/3)
}
}IMO, a library of such kind should not panic but return an error instead. let the user decide what to do.
gavraz, cyolosec and Delta456
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request