Skip to content

Commit

Permalink
Merge pull request #1087 from raidancampbell/bugfix/encoded-lambda-er…
Browse files Browse the repository at this point in the history
…ror-msg

Fix bug where FunctionError wasn't readable
  • Loading branch information
denis256 committed Apr 21, 2022
2 parents 5cce2ea + 2f0a77d commit 36cc060
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/aws/lambda.go
Expand Up @@ -170,7 +170,7 @@ type FunctionError struct {
}

func (err *FunctionError) Error() string {
return fmt.Sprintf("%s error invoking lambda function: %v", err.Message, err.Payload)
return fmt.Sprintf("%q error with status code %d invoking lambda function: %q", err.Message, err.StatusCode, err.Payload)
}

// NewLambdaClient creates a new Lambda client.
Expand Down
16 changes: 16 additions & 0 deletions modules/aws/lambda_test.go
@@ -0,0 +1,16 @@
package aws

import (
"github.com/stretchr/testify/require"
"testing"
)

func TestFunctionError(t *testing.T) {
t.Parallel()

// assert that the error message contains all the components of the error, in a readable form
err := &FunctionError{Message: "message", StatusCode: 123, Payload: []byte("payload")}
require.Contains(t, err.Error(), "message")
require.Contains(t, err.Error(), "123")
require.Contains(t, err.Error(), "payload")
}

0 comments on commit 36cc060

Please sign in to comment.