github.com/CyCoreSystems/ari@v4.8.4+incompatible/client/native/error.go (about) 1 package native 2 3 import ( 4 "fmt" 5 6 "github.com/pkg/errors" 7 ) 8 9 type errDataGet struct { 10 c error 11 entityType string 12 entityIDfmt string 13 entityIDctx []interface{} 14 } 15 16 func dataGetError(cause error, typ string, idfmt string, ctx ...interface{}) error { 17 if cause == nil { 18 return nil 19 } 20 21 return errors.WithStack(&errDataGet{ 22 c: cause, 23 entityType: typ, 24 entityIDfmt: idfmt, 25 entityIDctx: ctx, 26 }) 27 } 28 29 func (e *errDataGet) Error() string { 30 id := fmt.Sprintf(e.entityIDfmt, e.entityIDctx...) 31 return fmt.Sprintf("Error getting data for %v '%v': %v", e.entityType, id, e.c.Error()) 32 } 33 34 func (e *errDataGet) Cause() error { 35 return e.c 36 }