You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Which errors should be returned by Store implementations? #77
Now that the Store interface is available, it should be clarified which and what kind of errors should be returned by its implementations.
Example:AddEdge adds a new edge. Should the store return ErrEdgeAlready exists if the edge already exists, or should the Graph implementation check this in advance and return ErrEdgeAlready itself?
In short: Should a Store only handle technical errors or domain errors, too?
Advantages of only handling technical errors
The developer that implements a Store doesn't have to wrap their head around domain problems and focus on the actual storage logic. They don't need to be familiar with the behavior of the graph in edge cases.
Separation of concerns: The Store implementation stores data and does nothing else. Everything graph-related happens in the Graph implementations.
Advantages of handling technical and domain errors
More control over the behavior of the graph. If it is ok for the user to overwrite existing edges, they just don't return an error in AddEdge if the edge already exists and can safely rely on that.
I like the idea of the stores only handling technical errors so that the "business logic" of graphs stays in a single place.
We could even expand further on the separation by splitting out the errors that the stores are expected to return.
For example: graphs could return ErrEdgeAlreadyExists while stores return ErrStoreEdgeAlreadyExists
This would allow us to define a set of errors that stores are expected to return, that the graphs can then check and decide if they need to do something about it, or return a "graph" error.
Happy with both approaches btw, and also happy to update the stores to behave the way you think works better.
Activity
geoah commentedon Jan 26, 2023
I like the idea of the stores only handling technical errors so that the "business logic" of graphs stays in a single place.
We could even expand further on the separation by splitting out the errors that the stores are expected to return.
For example: graphs could return
ErrEdgeAlreadyExistswhile stores returnErrStoreEdgeAlreadyExistsThis would allow us to define a set of errors that stores are expected to return, that the graphs can then check and decide if they need to do something about it, or return a "graph" error.
Happy with both approaches btw, and also happy to update the stores to behave the way you think works better.