Implement errors.Is for Error type

This commit is contained in:
2022-10-25 17:54:27 +03:00
parent 3cfda09ced
commit 68d90a0496

View File

@@ -61,3 +61,12 @@ func (e *Error) Translate(ctx context.Context) string {
return printer.Sprintf(e.key, translatedParams...)
}
func (e *Error) Is(other error) bool {
switch err := other.(type) {
case *Error:
return e.key == err.key
}
return false
}