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

refactor(tm2/pkg/db): Avoid panicking when creating DBs. #726

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

ajnavarro
Copy link
Contributor

@ajnavarro ajnavarro commented Apr 10, 2023

Description

Refactor all DB New methods to avoid panicking.

Panic is not designed for error handling. Panic is designed for handling exceptional situations, like out-of-bounds array indexing. Using panic for error handling, we are swallowing some errors and we might cause inconsistent behavior not cleaning resources properly.

I tried to do this refactor as small as possible, modifying one interface and its implementations at a time, moving panics up into the stack, until eventually all panics are removed.

How has this been tested?

All existing tests have been refactored to check for errors.

Related issue: #532

Panic is not designed for error handling. Panic is designed for handling
exceptional situations, like out-of-bounds array indexing. Using panic
for error handling, we are swallowing some errors and we might cause
inconsistent behavior not cleaning resources properly.

Signed-off-by: Antonio Navarro <antnavper@gmail.com>
@ajnavarro ajnavarro requested a review from a team as a code owner April 10, 2023 06:56
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
@ajnavarro ajnavarro force-pushed the refactor/avoid-using-panic-on-db branch from bcf935b to fc2f28d Compare April 10, 2023 08:22
@moul moul merged commit d4e37cc into gnolang:master Apr 11, 2023
59 checks passed
@ajnavarro ajnavarro deleted the refactor/avoid-using-panic-on-db branch April 12, 2023 08:38
@piux2 piux2 requested a review from jaekwon April 22, 2023 05:39
peter7891 pushed a commit that referenced this pull request May 9, 2023
Co-authored-by: Antonio Navarro <ajnavarro@pop-os.localdomain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants