This patch extends the errors library accordingly.
Caveat: the doc says "if a.Is(b) is true, then errors.Is(a, b) is
true". This is the behavior implemented here. The doc does not say "if
a.Is(b) is false, then errors.Is(a, b) is false".
The CockroachDB errors library uses error identity markers which
enable comparisons across the network. The identity marker includes
only the type and message. Therefore, it is not possible to "make two
errors unequal" by customizing an Is() method to return false, if
their network identity marker is otherwise equal. To change this
behavior, use the errors.Mark() API instead, or implement an
ErrorTypeKey() method.
Fixes #58
The Go std
errors
package has this rule aboutIs()
:(source)
This patch extends the errors library accordingly.
Caveat: the doc says "if a.Is(b) is true, then errors.Is(a, b) is true". This is the behavior implemented here. The doc does not say "if a.Is(b) is false, then errors.Is(a, b) is false".
The CockroachDB errors library uses error identity markers which enable comparisons across the network. The identity marker includes only the type and message. Therefore, it is not possible to "make two errors unequal" by customizing an
Is()
method to returnfalse
, if their network identity marker is otherwise equal. To change this behavior, use theerrors.Mark()
API instead, or implement anErrorTypeKey()
method.Requested by @romariolopezc in #58
This change is![Reviewable](https://reviewable.io/review_button.svg)