Shallows icon indicating copy to clipboard operation
Shallows copied to clipboard

Clearer Error handling

Open ollitapa opened this issue 7 years ago • 3 comments

Would it be possible to define a common Error enum for the StorageProtocol? Seems that now the errors are simply Error protocol, so making switch cases to determine the real cause is difficult.

For example

enum StorageError {
    case general(error: Error)
    case write(error: Error)
    case noValue(for: Key)
}

ollitapa avatar Apr 02 '18 06:04 ollitapa

Hi! I’m sorry that I leaved this unaddressed for so long. This actually sounds like a reasonable idea, I’ll think about it definitely.

dreymonde avatar Apr 08 '18 19:04 dreymonde

No problem, thanks!

Also if you want to consider the Result object from here https://github.com/antitypical/Result I've seen it widely used and Shallows.Result conflicts with that type and namespace.

ollitapa avatar Apr 13 '18 10:04 ollitapa

I decided not to include antitypical/Result in Shallows because nested dependencies adds a lot of complexity, and usually are just not worth it. Most of the time, you won’t need to refer to Result directly, and when you need to, you can always unambiguate with Shallows.Result. It’s a tradeoff but I think it’s good enough.

dreymonde avatar Apr 15 '18 06:04 dreymonde