gitlab.com/evatix-go/core@v1.3.55/errcore/expected.go (about) 1 package errcore 2 3 import ( 4 "errors" 5 "fmt" 6 "reflect" 7 ) 8 9 type expected struct{} 10 11 func (it expected) But( 12 title interface{}, 13 wasExpecting, 14 actualReceived interface{}, 15 ) error { 16 return ExpectingErrorSimpleNoType( 17 title, 18 wasExpecting, 19 actualReceived) 20 } 21 22 func (it expected) ButFoundAsMsg( 23 title interface{}, 24 wasExpecting, 25 actualReceived interface{}, 26 ) string { 27 return ExpectingSimpleNoType( 28 title, 29 wasExpecting, 30 actualReceived) 31 } 32 33 func (it expected) ButFoundWithTypeAsMsg( 34 title interface{}, 35 wasExpecting, 36 actualReceived interface{}, 37 ) string { 38 return ExpectingSimple( 39 title, 40 wasExpecting, 41 actualReceived) 42 } 43 44 func (it expected) ButUsingType( 45 title interface{}, 46 wasExpecting, 47 actualReceived interface{}, 48 ) error { 49 return errors.New(ExpectingSimple( 50 title, 51 wasExpecting, 52 actualReceived)) 53 } 54 55 func (it expected) ReflectButFound( 56 expected, found reflect.Kind, 57 ) error { 58 return fmt.Errorf( 59 "expected [%v] but found [%v]", 60 expected.String(), found.String()) 61 } 62 63 func (it expected) PrimitiveButFound( 64 found reflect.Kind, 65 ) error { 66 return fmt.Errorf( 67 "expected [primitive] but found [%v]", 68 found.String()) 69 } 70 71 func (it expected) ValueHasNoElements( 72 typ reflect.Kind, 73 ) error { 74 return fmt.Errorf( 75 "generic value [%v] is nil or has no element", 76 typ.String()) 77 }