Skip to content

Commit

Permalink
Log function error on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
carlzogh committed Dec 8, 2021
1 parent 14da40f commit 76660fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lambda/invoke_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"strconv"
"time"

Expand Down Expand Up @@ -47,8 +48,9 @@ func handleInvoke(invoke *invoke, function *Function) error {
}

if functionResponse.Error != nil {
payload := safeMarshal(functionResponse.Error)
if err := invoke.failure(payload, contentTypeJSON); err != nil {
errorPayload := safeMarshal(functionResponse.Error)
log.Printf("%s", errorPayload)
if err := invoke.failure(errorPayload, contentTypeJSON); err != nil {
return fmt.Errorf("unexpected error occurred when sending the function error to the API: %v", err)
}
if functionResponse.Error.ShouldExit {
Expand Down

0 comments on commit 76660fc

Please sign in to comment.