diff --git a/lambda/invoke_loop.go b/lambda/invoke_loop.go index e558ea45..ab39147e 100644 --- a/lambda/invoke_loop.go +++ b/lambda/invoke_loop.go @@ -195,13 +195,17 @@ func makeXRayError(invokeResponseError *messages.InvokeResponse_Error) *xrayErro paths = append(paths, path) } cwd, _ := os.Getwd() + exceptions := []xrayException{{ + Type: invokeResponseError.Type, + Message: invokeResponseError.Message, + Stack: invokeResponseError.StackTrace, + }} + if exceptions[0].Stack == nil { + exceptions[0].Stack = []*messages.InvokeResponse_Error_StackFrame{} + } return &xrayError{ WorkingDirectory: cwd, Paths: paths, - Exceptions: []xrayException{{ - Type: invokeResponseError.Type, - Message: invokeResponseError.Message, - Stack: invokeResponseError.StackTrace, - }}, + Exceptions: exceptions, } } diff --git a/lambda/invoke_loop_test.go b/lambda/invoke_loop_test.go index a3a2fcd0..f0e236b9 100644 --- a/lambda/invoke_loop_test.go +++ b/lambda/invoke_loop_test.go @@ -92,6 +92,7 @@ func TestCustomErrorMarshaling(t *testing.T) { func TestXRayCausePlumbing(t *testing.T) { errors := []error{ + errors.New("barf"), messages.InvokeResponse_Error{ Type: "yoloError", Message: "hello yolo", @@ -100,9 +101,24 @@ func TestXRayCausePlumbing(t *testing.T) { {Label: "hi", Path: "hello/hello", Line: 12}, }, }, + messages.InvokeResponse_Error{ + Type: "yoloError", + Message: "hello yolo", + StackTrace: []*messages.InvokeResponse_Error_StackFrame{ + }, + }, } wd, _ := os.Getwd() expected := []string{ + `{ + "working_directory":"` + wd + `", + "paths": [], + "exceptions": [{ + "type": "errorString", + "message": "barf", + "stack": [] + }] + }`, `{ "working_directory":"` + wd + `", "paths": ["yolo", "hello/hello"], @@ -115,6 +131,17 @@ func TestXRayCausePlumbing(t *testing.T) { ] }] }`, + `{ + "working_directory":"` + wd + `", + "paths": [], + "exceptions": [{ + "type": "yoloError", + "message": "hello yolo", + "stack": [ + ] + }] + }`, + } require.Equal(t, len(errors), len(expected)) ts, record := runtimeAPIServer(``, len(errors))