Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where FunctionError wasn't readable #1087

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/aws/lambda.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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")
}