gitlab.com/evatix-go/core@v1.3.55/corefuncs/InOutErrFuncWrapper.go (about) 1 package corefuncs 2 3 import "gitlab.com/evatix-go/core/errcore" 4 5 type InOutErrFuncWrapper struct { 6 Name string 7 Action InOutErrFunc 8 } 9 10 func (it InOutErrFuncWrapper) Exec( 11 input interface{}, 12 ) (output interface{}, err error) { 13 return it.Action(input) 14 } 15 16 func (it InOutErrFuncWrapper) AsActionFunc(input interface{}) ActionFunc { 17 return func() { 18 errcore.MustBeEmpty( 19 it.AsActionReturnsErrorFunc(input)()) 20 } 21 } 22 23 func (it InOutErrFuncWrapper) AsActionReturnsErrorFunc( 24 input interface{}, 25 ) ActionReturnsErrorFunc { 26 return func() error { 27 _, err := it.Action(input) 28 29 if err != nil { 30 return errcore. 31 FailedToExecuteType. 32 Error(err.Error()+", function name:", it.Name) 33 } 34 35 return err 36 } 37 }