MCPcopy Index your code
hub / github.com/aws/aws-lambda-go / validateReturns

Function validateReturns

lambda/handler.go:126–143  ·  view source on GitHub ↗
(handler reflect.Type)

Source from the content-addressed store, hash-verified

124}
125
126func validateReturns(handler reflect.Type) error {
127 errorType := reflect.TypeOf((*error)(nil)).Elem()
128
129 switch n := handler.NumOut(); {
130 case n > 2:
131 return fmt.Errorf("handler may not return more than two values")
132 case n > 1:
133 if !handler.Out(1).Implements(errorType) {
134 return fmt.Errorf("handler returns two values, but the second does not implement error")
135 }
136 case n == 1:
137 if !handler.Out(0).Implements(errorType) {
138 return fmt.Errorf("handler returns a single value, but it does not implement error")
139 }
140 }
141
142 return nil
143}
144
145// NewHandler creates a base lambda handler from the given handler function. The
146// returned Handler performs JSON serialization and deserialization, and

Callers 2

TestStartHandlerFuncFunction · 0.85
reflectHandlerFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStartHandlerFuncFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…