Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on non-fatal errors #232

Open
jm33-m0 opened this issue Dec 21, 2024 · 1 comment
Open

Panic on non-fatal errors #232

jm33-m0 opened this issue Dec 21, 2024 · 1 comment

Comments

@jm33-m0
Copy link

jm33-m0 commented Dec 21, 2024

For example:

func (t *Table) SetColumnColor(colors ...Colors) {
if t.colSize != len(colors) {
panic("Number of column colors must be equal to number of headers.")
}
for i := 0; i < len(colors); i++ {
t.columnsParams = append(t.columnsParams, makeSequence(colors[i]))
}
}

Just because the table writer can't print a table doesn't mean we have to kill the whole program. I suggest changing all panics to logging, if needed I will open a pull request.

Thanks!

@jm33-m0
Copy link
Author

jm33-m0 commented Dec 21, 2024

Instead of killing the whole process, we should just print a warning telling the user what is wrong, so the user will see the error rather than a table.

jm33-m0 added a commit to jm33-m0/tablewriter that referenced this issue Dec 21, 2024
@jm33-m0 jm33-m0 changed the title Unnecessary panic Panic on non-fatal errors Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant