MCPcopy Create free account
hub / github.com/erpc/erpc / HasCode

Method HasCode

common/errors.go:365–388  ·  view source on GitHub ↗
(codes ...ErrorCode)

Source from the content-addressed store, hash-verified

363}
364
365func (e *BaseError) HasCode(codes ...ErrorCode) bool {
366 for _, code := range codes {
367 if e.Code == code {
368 return true
369 }
370 }
371
372 if e.Cause != nil {
373 if be, ok := e.Cause.(StandardError); ok {
374 return be.HasCode(codes...)
375 }
376 if cs, ok := e.Cause.(interface{ Unwrap() []error }); ok {
377 for _, err := range cs.Unwrap() {
378 if be, ok := err.(StandardError); ok {
379 if be.HasCode(codes...) {
380 return true
381 }
382 }
383 }
384 }
385 }
386
387 return false
388}
389
390func (e *BaseError) Base() *BaseError {
391 return e

Callers

nothing calls this directly

Calls 2

HasCodeMethod · 0.65
UnwrapMethod · 0.45

Tested by

no test coverage detected