MCPcopy
hub / github.com/duke-git/lancet / Is

Method Is

xerror/xerror.go:134–144  ·  view source on GitHub ↗

Is checks if target error is XError and Error.id of two errors are matched.

(target error)

Source from the content-addressed store, hash-verified

132
133// Is checks if target error is XError and Error.id of two errors are matched.
134func (e *XError) Is(target error) bool {
135 var err *XError
136
137 if errors.As(target, &err) {
138 if e.id != "" && e.id == err.id {
139 return true
140 }
141 }
142
143 return e == target
144}
145
146// Id sets id to check equality in XError.Is
147func (e *XError) Id(id string) *XError {

Callers 5

ExampleXError_IdFunction · 0.80
ExampleXError_IsFunction · 0.80
TestRetryFailedFunction · 0.80
IsExistFunction · 0.80

Calls

no outgoing calls

Tested by 4

ExampleXError_IdFunction · 0.64
ExampleXError_IsFunction · 0.64
TestRetryFailedFunction · 0.64