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

Do not try to recover from panics, but use the return values #133

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

svanharmelen
Copy link
Contributor

Sorry for all the PRs, I'm just having fun with it and am hitting a lot of small issues when using lazysql which I would like to help improve 😉

This PR removes all the calls to recover as it is very discouraged (see Go docs) to try and recover panics as in in 99.999999% of the cases that indicates a bug in the program or another error not being handled properly which should be fixed instead.

In order to take any actions using a defer that will only do something if the function returned an error, its best to just check against that error. While in Go its no too common to use named return values in the function signature, in the case where you want a defer to have access to the actual returned value I found it to be the most robust to at least name the error in the function signature. But in this case I noticed you already named all return values so I didn't need to change anything for that.

@jorgerojas26
Copy link
Owner

That is fair enough :) just fix the linter issues and i'll merge.

@jorgerojas26
Copy link
Owner

jorgerojas26 commented Nov 22, 2024

Thanks for all the PRs, by the way. I'm just a bit busy right now, but i'll try to follow all of them.

@svanharmelen
Copy link
Contributor Author

The linter issue is fixed by #132 I think the linter updated as I didn't tough that code...

@jorgerojas26
Copy link
Owner

There are other linter issues in ResultsTable.go:814 and ConnectionsTable.go:77

@svanharmelen
Copy link
Contributor Author

Ah sorry, missed that one! Should be fixed now...

@svanharmelen
Copy link
Contributor Author

Addressed all feedback and rebased all PRs so they pass the linter again 👍🏻

@jorgerojas26 jorgerojas26 merged commit 105fddb into jorgerojas26:main Nov 22, 2024
2 checks passed
@svanharmelen svanharmelen deleted the feat/errors branch November 22, 2024 15:35
Kuchteq pushed a commit to Kuchteq/lazysql that referenced this pull request Nov 25, 2024
Do not try to recover from panics, but use the return values
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

Successfully merging this pull request may close these issues.

2 participants