diff --git a/modules/aws/lambda.go b/modules/aws/lambda.go index 634d7290a..5630613ca 100644 --- a/modules/aws/lambda.go +++ b/modules/aws/lambda.go @@ -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. diff --git a/modules/aws/lambda_test.go b/modules/aws/lambda_test.go new file mode 100644 index 000000000..053f2bda4 --- /dev/null +++ b/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") +}