diff --git a/client.go b/client.go index ee40e9832..9c7a002f7 100644 --- a/client.go +++ b/client.go @@ -32,10 +32,10 @@ type ClientOptions struct { // In debug mode debug information is printed to stdput to help you understand what // sentry is doing. Debug bool - // The sample rate for event submission (0.0 - 1.0, defaults to 1.0) - SampleRate float32 // Configures whether SDK should generate and attach stacktraces to pure capture message calls AttachStacktrace bool + // The sample rate for event submission (0.0 - 1.0, defaults to 1.0) + SampleRate float32 // Before send callback. BeforeSend func(event *Event, hint *EventHint) *Event // Before breadcrumb add callback. @@ -240,7 +240,7 @@ func (client *Client) eventFromMessage(message string, level Level) *Event { Message: message, } - if client.Options().AttachStacktrace == true { + if client.Options().AttachStacktrace { event.Threads = []Thread{{ Stacktrace: NewStacktrace(), Crashed: false, diff --git a/example/recover/main.go b/example/recover/main.go index 24c61e176..068d9562e 100644 --- a/example/recover/main.go +++ b/example/recover/main.go @@ -23,7 +23,7 @@ func barErr() { } func bazErr() { - panic(errors.New("Sorry with error :(")) + panic(errors.New("sorry with error :(")) } func fooMsg() { @@ -35,7 +35,7 @@ func barMsg() { } func bazMsg() { - panic("Sorry with message :(") + panic("sorry with message :(") } func main() { diff --git a/stacktrace.go b/stacktrace.go index 81f17d9ba..f394fc3e0 100644 --- a/stacktrace.go +++ b/stacktrace.go @@ -228,16 +228,14 @@ func contextifyFrames(frames []Frame) []Frame { for _, frame := range frames { lines, initial := sr.readContextLines(frame.AbsPath, frame.Lineno, contextLines) - if lines != nil { - for i, line := range lines { - switch { - case i < initial: - frame.PreContext = append(frame.PreContext, string(line)) - case i == initial: - frame.ContextLine = string(line) - default: - frame.PostContext = append(frame.PostContext, string(line)) - } + for i, line := range lines { + switch { + case i < initial: + frame.PreContext = append(frame.PreContext, string(line)) + case i == initial: + frame.ContextLine = string(line) + default: + frame.PostContext = append(frame.PostContext, string(line)) } } diff --git a/stacktrace_test.go b/stacktrace_test.go index 11ba0229e..e61f3409b 100644 --- a/stacktrace_test.go +++ b/stacktrace_test.go @@ -74,20 +74,21 @@ func TestStacktraceFrameContext(t *testing.T) { func TestStacktraceUnsuccessfulContextifyShouldNotDropFrames(t *testing.T) { frames := []Frame{{ - Function: "fnName", - Module: "same", - Filename: "wat.go", - AbsPath: "this/doesnt/exist/wat.go", - Lineno: 1, - Colno: 2, + Function: "fnName", + Module: "same", + Filename: "wat.go", + AbsPath: "this/doesnt/exist/wat.go", + Lineno: 1, + Colno: 2, }, { - Function: "fnNameFoo", - Module: "sameFoo", - Filename: "foo.go", - AbsPath: "this/doesnt/exist/foo.go", - Lineno: 3, - Colno: 5, + Function: "fnNameFoo", + Module: "sameFoo", + Filename: "foo.go", + AbsPath: "this/doesnt/exist/foo.go", + Lineno: 3, + Colno: 5, }} + contextifiedFrames := contextifyFrames(frames) assertEqual(t, len(contextifiedFrames), len(frames)) }