Skip to content

Question: The signatures of the Store interface methods #9

Open
@rumyantseva

Description

@rumyantseva

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions