in fc/invoke_loop.go [55:81]
func handleInvoke(invokeInstance *invoke, function *Function) error {
functionRequest, err := convertInvokeRequest(invokeInstance)
if err != nil {
return fmt.Errorf("unexpected error occurred when parsing the invoke: %v", err)
}
functionResponse := &messages.InvokeResponse{}
ivkErr := function.Invoke(functionRequest, functionResponse, convertInvokeFunctionType(invokeInstance))
if functionResponse.Error != nil {
payload := safeMarshal(functionResponse.Error)
if err := invokeInstance.failure(payload, contentTypeJSON); err != nil {
return fmt.Errorf("unexpected error occurred when sending the function error to the API: %v", err)
}
if functionResponse.Error.ShouldExit {
return fmt.Errorf("calling the handler function resulted in a panic")
}
return ivkErr
}
if ivkErr != nil {
return ivkErr
}
if err := invokeInstance.success(functionResponse.Payload, contentTypeJSON, functionResponse.HttpParam); err != nil {
return fmt.Errorf("unexpected error occurred when sending the function functionResponse to the API: %v", err)
}
return nil
}