-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Return error instead of panicking when modifying a sealed app #11600
Comments
Yeah, I've read the comments from @peterbourgon. I don't necessarily think or agree that all panics are solely for programming errors as there are certain exceptions where you want to halt/exit as early as possible. However, I do agree that we should probably consider returning an error here. But all this will do is bubble the error upstream, where we will just panic or exit anyway (e.g. from a CLI command handler). |
I think panic is the correct behavior here, theres nothing else to do with errors in initialization, and we then waste even more error checks everywhere, further adding complexity to logic that should be simple glueing of things. |
(The SDK gets this super duper wrong, and its systemic misuse of |
@ValarDragon is correct here though, we want to panic when the application is sealed. We can certainly return an error and bubble it, but we'd end up either panicing or exiting only one layer up, which doesn't really buy us much. |
As for resolving this issue, I'm open to returning errors and having the SDK exit upon non-nil errors in the |
If the caller can't do anything to fix the problem and will just exist, and the caller can't add any more valuable context to the situation, I don't get why If error handling were a minimal cognitive overhead for the reader, e.g. like in rust with the |
The problem is that
I understand this perspective, but it's not an objective truth, and it's certainly not true for Go. In Go, error handling is explicit. That's just a fact of the language, and something that Go programmers must necessarily understand and adopt in order to be productive.
A
This is correct —
|
I'm claiming that this isn't true. |
The linked effective go even says panicing is fine for initialzation though?
|
Yes, but initialization in that context means e.g. Concretely,
Modifying a sealed app is a logic error, and a bug, but not an unrecoverable condition. The result is obvious: simply reject the modification with an error. In fact every fallible operation should return |
Please re-open this issue. |
I don't think there is a need to bubble up these errors upon app initialization 👍 |
Background
The
sealed
flag in baseapp is true when the app should not be modified further. It is set whenbaseapp.Init()
orbaseapp.Seal()
are called.Currently, if an attempt to modify a sealed app is made, the SDK panics. However, it might be better to return an error.
This issue is to change all baseapp modifiers to return the error instead of panicking.
Some more context is in this thread:
#11496 (comment)
Several methods are located in the
options.go
Acceptance Criteria
The text was updated successfully, but these errors were encountered: