-
Notifications
You must be signed in to change notification settings - Fork 55
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
Single place to handle errors in a function #337
Comments
I agree that we should find a way to handle this case better. This is the Go 2 draft, which has lots of useful discussion. The are a number of things to keep in mind here:
|
Unfortunately, we have used up the word One possibility is something like Swift's do/catch. Swift's |
I've made a comment in the lang repo but I guess this is the right place:
In comparison, this is how one can extend an ASP.NET Core application with an extension method made available by Sentry's package: The framework offers hooks that can be used from that simple code change done by the application developer. |
The transaction proposal change to check semantics provides a way to solve this |
@jclark can you please provide more details on what block statements are going to support the on-fail clause. Below are the block statements that I could think of,
Do we need to consider below block statements as well?
What are the principles that we need to consider when deciding the block statements? |
The principle is that it should work for any block statement that has the syntactic form
unless it wouldn’t make sense or would be syntactically confusing. So, for example, it should not work for |
Note that |
Grammar changes done. Rearrange statement subsections. Part of #337.
Grammar changes now in. |
Consider the following program. My aim is to provide a public API to retrieve sunrise/sunset times of a given city. The function
sunriseSunsetInternal
has to the logic, but it does contain manycheck
operator usages, simply because I don't want to handle errors at every line. That would make this unreadable. I also want to give a proper error for all my API users. This is the only approach that I can think of.Can we think of an "error handler" concept? This has been proposed in Go 2 draft as well.
The text was updated successfully, but these errors were encountered: