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

Question: The signatures of the Store interface methods #9

Open
rumyantseva opened this issue May 29, 2017 · 1 comment
Open

Question: The signatures of the Store interface methods #9

rumyantseva opened this issue May 29, 2017 · 1 comment
Milestone

Comments

@rumyantseva
Copy link

rumyantseva commented May 29, 2017

I have a question about dealing with errors.
The signatures of the Store interface methods don't have error as return value.
What is the best way to deal with errors in this case?

For example, if I use database, in case of error I'd like to return error to the part of code which asked for the method. The Store interface methods don't give me this possibility, so the only way is to return nil and log error. But in some cases I'd like to tell user that something went wrong instead of pretending that session was saved.

For example, I want something like this:

err := session.Add(sessionData, c.Writer)
if err != nil {
  // return 500 error
}

But I have only this:

session.Add(sessionData, c.Writer)
// How can I understand that something went wrong?

Do you think if it is possible to add error to the signatures in the next major version of the library?

@rumyantseva rumyantseva changed the title [Question] The signatures of the Store interface methods Question: The signatures of the Store interface methods May 29, 2017
@icza
Copy link
Owner

icza commented May 29, 2017

Good idea, it might have been an overlook from my part when designing the API.

Similarly, if we proceed to add an error return value too to the Store methods, we should do the same with the Manager interface (a Manager implementation uses a Store implementation under the hood, and it is reasonable / makes sense to "delegate" the errors returned by the used Store).

@icza icza added this to the v2.0.0 milestone May 29, 2017
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

2 participants