jepsen-io / maelstrom

A workbench for writing toy implementations of distributed systems.
Eclipse Public License 1.0
3.05k stars 189 forks source link

maelstrom.ErrorCode: support errors nesting #54

Closed sitano closed 1 year ago

sitano commented 1 year ago

Go framework needs to support errors nesting via "errors" package:

err = fmt.Errorf("foo: %w", error(maelstrom.NewRPCError(maelstrom.Crash, "foo")))
if maelstrom.ErrorCode(err) == maelstrom.Crash {
    // do something useful
}

For checking wrapped errors returned from KV and another API that can fail due to whatever reason including context timeouts

aphyr commented 1 year ago

Seems... reasonable! I'm completely unqualified to review Go, so hopefully this doesn't break anything. :-)