-
Notifications
You must be signed in to change notification settings - Fork 69
/
bugsnag_test.go
627 lines (533 loc) · 20.3 KB
/
bugsnag_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
package bugsnag
import (
"context"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/bitly/go-simplejson"
"github.com/bugsnag/bugsnag-go/sessions"
)
// The line numbers of this method are used in tests.
// If you move this function you'll have to change tests
func crashyHandler(w http.ResponseWriter, r *http.Request) {
c := make(chan int)
close(c)
c <- 1
}
type _recurse struct {
Recurse *_recurse
}
const (
unhandled = true
handled = false
)
var testAPIKey = "166f5ad3590596f9aa8d601ea89af845"
type logger struct{ msg string }
func (l *logger) Printf(format string, v ...interface{}) { l.msg = format }
// setup sets up a simple sessionTracker and returns a test event server for receiving the event payloads.
// report payloads published to the returned server's URL will be put on the returned channel
func setup() (*httptest.Server, chan []byte) {
reports := make(chan []byte, 10)
sessionTracker = &testSessionTracker{}
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
reports <- body
})), reports
}
type testSessionTracker struct{}
func (t *testSessionTracker) StartSession(context.Context) context.Context {
return context.Background()
}
func (t *testSessionTracker) IncrementEventCountAndGetSession(context.Context, bool) *sessions.Session {
return &sessions.Session{}
}
func (t *testSessionTracker) FlushSessions() {}
func TestConfigure(t *testing.T) {
Configure(Configuration{
APIKey: testAPIKey,
})
if Config.APIKey != testAPIKey {
t.Errorf("Setting APIKey didn't work")
}
if New().Config.APIKey != testAPIKey {
t.Errorf("Setting APIKey didn't work for new notifiers")
}
}
func TestNotify(t *testing.T) {
ts, reports := setup()
defer ts.Close()
sessionTracker = nil
startSessionTracking()
recurse := _recurse{}
recurse.Recurse = &recurse
OnBeforeNotify(func(event *Event, config *Configuration) error {
if event.Context == "testing" {
event.GroupingHash = "lol"
}
return nil
})
md := MetaData{"test": {"password": "sneaky", "value": "able", "broken": complex(1, 2), "recurse": recurse}}
user := User{Id: "123", Name: "Conrad", Email: "[email protected]"}
config := generateSampleConfig(ts.URL)
Notify(fmt.Errorf("hello world"), StartSession(context.Background()), config, user, ErrorClass{Name: "ExpectedErrorClass"}, Context{"testing"}, md)
json, err := simplejson.NewJson(<-reports)
if err != nil {
t.Fatal(err)
}
event := getIndex(json, "events", 0)
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "testing",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "lol",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "warning",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledError},
Unhandled: false,
Request: &RequestJSON{},
User: &User{Id: "123", Name: "Conrad", Email: "[email protected]"},
Exceptions: []exceptionJSON{{ErrorClass: "ExpectedErrorClass", Message: "hello world"}},
})
assertValidSession(t, event, handled)
for k, exp := range map[string]string{
"metaData.test.password": "[FILTERED]",
"metaData.test.value": "able",
"metaData.test.broken": "[complex128]",
"metaData.test.recurse.Recurse": "[RECURSION]",
} {
if got := getString(event, k); got != exp {
t.Errorf("Expected %s to be '%s' but was '%s'", k, exp, got)
}
}
exception := getIndex(event, "exceptions", 0)
verifyExistsInStackTrace(t, exception, &StackFrame{File: "bugsnag_test.go", Method: "TestNotify", LineNumber: 98, InProject: true})
}
type testPublisher struct {
sync bool
}
func (tp *testPublisher) publishReport(p *payload) error {
tp.sync = p.Synchronous
return nil
}
func TestNotifySyncThenAsync(t *testing.T) {
ts, _ := setup()
defer ts.Close()
Configure(generateSampleConfig(ts.URL)) //async by default
pub := new(testPublisher)
publisher = pub
defer func() { publisher = new(defaultReportPublisher) }()
Notify(fmt.Errorf("oopsie"))
if pub.sync {
t.Errorf("Expected notify to be async by default")
}
defaultNotifier.NotifySync(fmt.Errorf("oopsie"), true)
if !pub.sync {
t.Errorf("Expected notify to be sent synchronously when calling NotifySync with true")
}
Notify(fmt.Errorf("oopsie"))
if pub.sync {
t.Errorf("Expected notify to be sent asynchronously when calling Notify regardless of previous NotifySync call")
}
}
func TestHandlerFunc(t *testing.T) {
eventserver, reports := setup()
defer eventserver.Close()
Configure(generateSampleConfig(eventserver.URL))
t.Run("unhandled", func(st *testing.T) {
sessionTracker = nil
startSessionTracking()
ts := httptest.NewServer(HandlerFunc(crashyHandler))
defer ts.Close()
http.Get(ts.URL + "/unhandled")
json, _ := simplejson.NewJson(<-reports)
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "/unhandled",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "error",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledPanic},
Unhandled: true,
Request: &RequestJSON{
Headers: map[string]string{"Accept-Encoding": "gzip"},
HTTPMethod: "GET",
URL: ts.URL + "/unhandled",
},
User: &User{Id: "127.0.0.1", Name: "", Email: ""},
Exceptions: []exceptionJSON{{ErrorClass: "runtime.plainError", Message: "send on closed channel"}},
})
event := getIndex(json, "events", 0)
if got, exp := getString(event, "request.headers.Accept-Encoding"), "gzip"; got != exp {
st.Errorf("expected Accept-Encoding header to be '%s' but was '%s'", exp, got)
}
if got, exp := getString(event, "request.httpMethod"), "GET"; got != exp {
st.Errorf("expected HTTP method to be '%s' but was '%s'", exp, got)
}
if got, exp := getString(event, "request.url"), "/unhandled"; !strings.Contains(got, exp) {
st.Errorf("expected request URL to contain '%s' but was '%s'", exp, got)
}
assertValidSession(st, event, unhandled)
})
t.Run("handled", func(st *testing.T) {
ts := httptest.NewServer(HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Notify(fmt.Errorf("oopsie"), r.Context())
}))
defer ts.Close()
http.Get(ts.URL + "/handled")
json, _ := simplejson.NewJson(<-reports)
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "/handled",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 1, Unhandled: 0}},
Severity: "warning",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledError},
Unhandled: false,
Request: &RequestJSON{
Headers: map[string]string{"Accept-Encoding": "gzip"},
HTTPMethod: "GET",
URL: ts.URL + "/handled",
},
User: &User{Id: "127.0.0.1", Name: "", Email: ""},
Exceptions: []exceptionJSON{{ErrorClass: "*errors.errorString", Message: "oopsie"}},
})
event := getIndex(json, "events", 0)
if got, exp := getString(event, "request.headers.Accept-Encoding"), "gzip"; got != exp {
st.Errorf("expected Accept-Encoding header to be '%s' but was '%s'", exp, got)
}
if got, exp := getString(event, "request.httpMethod"), "GET"; got != exp {
st.Errorf("expected HTTP method to be '%s' but was '%s'", exp, got)
}
if got, exp := getString(event, "request.url"), "/handled"; !strings.Contains(got, exp) {
st.Errorf("expected request URL to contain '%s' but was '%s'", exp, got)
}
assertValidSession(st, event, handled)
})
}
func TestHandler(t *testing.T) {
ts, reports := setup()
defer ts.Close()
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
defer l.Close()
mux := http.NewServeMux()
mux.HandleFunc("/", crashyHandler)
go (&http.Server{
Addr: l.Addr().String(),
Handler: Handler(mux, generateSampleConfig(ts.URL), SeverityInfo),
ErrorLog: log.New(ioutil.Discard, log.Prefix(), 0),
}).Serve(l)
sessionTracker = nil
startSessionTracking()
http.Get("http://" + l.Addr().String() + "/ok?foo=bar")
json, err := simplejson.NewJson(<-reports)
if err != nil {
t.Fatal(err)
}
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "/ok",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "info",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledPanic},
Unhandled: true,
User: &User{Id: "127.0.0.1", Name: "", Email: ""},
Request: &RequestJSON{
Headers: map[string]string{"Accept-Encoding": "gzip"},
HTTPMethod: "GET",
URL: "http://" + l.Addr().String() + "/ok?foo=bar",
},
Exceptions: []exceptionJSON{{ErrorClass: "runtime.plainError", Message: "send on closed channel"}},
})
event := getIndex(json, "events", 0)
if got, exp := getString(event, "request.headers.Accept-Encoding"), "gzip"; got != exp {
t.Errorf("expected Accept-Encoding header to be '%s' but was '%s'", exp, got)
}
if got, exp := getString(event, "request.httpMethod"), "GET"; got != exp {
t.Errorf("expected HTTP method to be '%s' but was '%s'", exp, got)
}
if got, exp := getString(event, "request.url"), "/ok?foo=bar"; !strings.Contains(got, exp) {
t.Errorf("expected request URL to be '%s' but was '%s'", exp, got)
}
assertValidSession(t, event, unhandled)
if got, exp := getFirstString(event, "metaData.request.params.foo"), "bar"; got != exp {
t.Errorf("Expected metadata params 'foo' to be '%s' but was '%s'", exp, got)
}
exception := getIndex(event, "exceptions", 0)
verifyExistsInStackTrace(t, exception, &StackFrame{File: "bugsnag_test.go", Method: "crashyHandler", InProject: true, LineNumber: 24})
}
func TestAutoNotify(t *testing.T) {
ts, reports := setup()
defer ts.Close()
var panicked error
func() {
defer func() {
p := recover()
switch p.(type) {
case error:
panicked = p.(error)
default:
t.Fatalf("Unexpected panic happened. Expected 'eggs' Error but was a(n) <%T> with value <%+v>", p, p)
}
}()
defer AutoNotify(StartSession(context.Background()), generateSampleConfig(ts.URL))
panic(fmt.Errorf("eggs"))
}()
if panicked.Error() != "eggs" {
t.Errorf("didn't re-panic")
}
json, err := simplejson.NewJson(<-reports)
if err != nil {
t.Fatal(err)
}
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "error",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledPanic},
Unhandled: true,
User: &User{},
Request: &RequestJSON{},
Exceptions: []exceptionJSON{{ErrorClass: "*errors.errorString", Message: "eggs"}},
})
}
func TestRecover(t *testing.T) {
ts, reports := setup()
defer ts.Close()
var panicked interface{}
func() {
defer func() {
panicked = recover()
}()
defer Recover(StartSession(context.Background()), generateSampleConfig(ts.URL))
panic("ham")
}()
if panicked != nil {
t.Errorf("Did not expect a panic but repanicked")
}
json, err := simplejson.NewJson(<-reports)
if err != nil {
t.Fatal(err)
}
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "warning",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledPanic},
Unhandled: false,
Request: &RequestJSON{},
User: &User{},
Exceptions: []exceptionJSON{{ErrorClass: "*errors.errorString", Message: "ham"}},
})
}
func TestRecoverCustomHandledState(t *testing.T) {
ts, reports := setup()
defer ts.Close()
var panicked interface{}
func() {
defer func() {
panicked = recover()
}()
handledState := HandledState{
SeverityReason: SeverityReasonHandledPanic,
OriginalSeverity: SeverityError,
Unhandled: true,
}
defer Recover(handledState, StartSession(context.Background()), generateSampleConfig(ts.URL))
panic("at the disco?")
}()
if panicked != nil {
t.Errorf("Did not expect a panic but repanicked")
}
json, err := simplejson.NewJson(<-reports)
if err != nil {
t.Fatal(err)
}
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "error",
SeverityReason: &severityReasonJSON{Type: SeverityReasonHandledPanic},
Unhandled: true,
Request: &RequestJSON{},
User: &User{},
Exceptions: []exceptionJSON{{ErrorClass: "*errors.errorString", Message: "at the disco?"}},
})
}
func TestSeverityReasonNotifyCallback(t *testing.T) {
ts, reports := setup()
defer ts.Close()
OnBeforeNotify(func(event *Event, config *Configuration) error {
event.Severity = SeverityInfo
return nil
})
Notify(fmt.Errorf("hello world"), generateSampleConfig(ts.URL), StartSession(context.Background()))
json, _ := simplejson.NewJson(<-reports)
assertPayload(t, json, eventJSON{
App: &appJSON{ReleaseStage: "test", Type: "foo", Version: "1.2.3"},
Context: "",
Device: &deviceJSON{Hostname: "web1"},
GroupingHash: "",
Session: &sessionJSON{Events: sessions.EventCounts{Handled: 0, Unhandled: 1}},
Severity: "info",
SeverityReason: &severityReasonJSON{Type: SeverityReasonCallbackSpecified},
Unhandled: false,
Request: &RequestJSON{},
User: &User{},
Exceptions: []exceptionJSON{{ErrorClass: "*errors.errorString", Message: "hello world"}},
})
}
func TestNotifyWithoutError(t *testing.T) {
ts, reports := setup()
defer ts.Close()
config := generateSampleConfig(ts.URL)
config.Synchronous = true
l := logger{}
config.Logger = &l
Configure(config)
Notify(nil, StartSession(context.Background()))
select {
case r := <-reports:
t.Fatalf("Unexpected request made to bugsnag: %+v", string(r))
default:
for _, exp := range []string{"ERROR", "error", "Bugsnag", "not notified"} {
if got := l.msg; !strings.Contains(got, exp) {
t.Errorf("Expected to see '%s' in logged message but logged message was '%s'", exp, got)
}
}
}
}
func TestConfigureTwice(t *testing.T) {
Configure(Configuration{})
if !Config.IsAutoCaptureSessions() {
t.Errorf("Expected auto capture sessions to be enabled by default")
}
Configure(Configuration{AutoCaptureSessions: false})
if Config.IsAutoCaptureSessions() {
t.Errorf("Expected auto capture sessions to be disabled when configured")
}
Configure(Configuration{AutoCaptureSessions: true})
if !Config.IsAutoCaptureSessions() {
t.Errorf("Expected auto capture sessions to be enabled when configured")
}
}
func generateSampleConfig(endpoint string) Configuration {
return Configuration{
APIKey: testAPIKey,
Endpoints: Endpoints{Notify: endpoint},
ProjectPackages: []string{"github.com/bugsnag/bugsnag-go"},
Logger: log.New(ioutil.Discard, log.Prefix(), log.Flags()),
ReleaseStage: "test",
AppType: "foo",
AppVersion: "1.2.3",
Hostname: "web1",
}
}
func get(j *simplejson.Json, path string) *simplejson.Json {
return j.GetPath(strings.Split(path, ".")...)
}
func getBool(j *simplejson.Json, path string) bool {
return get(j, path).MustBool()
}
func getInt(j *simplejson.Json, path string) int {
return get(j, path).MustInt()
}
func getString(j *simplejson.Json, path string) string {
return get(j, path).MustString()
}
func getIndex(j *simplejson.Json, path string, index int) *simplejson.Json {
return get(j, path).GetIndex(index)
}
func getFirstString(j *simplejson.Json, path string) string {
return getIndex(j, path, 0).MustString()
}
// assertPayload compares the payload that was received by the event-server to
// the expected report JSON payload
func assertPayload(t *testing.T, report *simplejson.Json, exp eventJSON) {
expException := exp.Exceptions[0]
event := getIndex(report, "events", 0)
exception := getIndex(event, "exceptions", 0)
for _, tc := range []struct {
prop string
exp, got interface{}
}{
{prop: "API Key", exp: testAPIKey, got: getString(report, "apiKey")},
{prop: "notifier name", exp: "Bugsnag Go", got: getString(report, "notifier.name")},
{prop: "notifier version", exp: VERSION, got: getString(report, "notifier.version")},
{prop: "notifier url", exp: "https://github.com/bugsnag/bugsnag-go", got: getString(report, "notifier.url")},
{prop: "exception message", exp: expException.Message, got: getString(exception, "message")},
{prop: "exception error class", exp: expException.ErrorClass, got: getString(exception, "errorClass")},
{prop: "unhandled", exp: exp.Unhandled, got: getBool(event, "unhandled")},
{prop: "app version", exp: exp.App.Version, got: getString(event, "app.version")},
{prop: "app release stage", exp: exp.App.ReleaseStage, got: getString(event, "app.releaseStage")},
{prop: "app type", exp: exp.App.Type, got: getString(event, "app.type")},
{prop: "user id", exp: exp.User.Id, got: getString(event, "user.id")},
{prop: "user name", exp: exp.User.Name, got: getString(event, "user.name")},
{prop: "user email", exp: exp.User.Email, got: getString(event, "user.email")},
{prop: "context", exp: exp.Context, got: getString(event, "context")},
{prop: "device hostname", exp: exp.Device.Hostname, got: getString(event, "device.hostname")},
{prop: "grouping hash", exp: exp.GroupingHash, got: getString(event, "groupingHash")},
{prop: "payload version", exp: "4", got: getString(event, "payloadVersion")},
{prop: "severity", exp: exp.Severity, got: getString(event, "severity")},
{prop: "severity reason type", exp: string(exp.SeverityReason.Type), got: getString(event, "severityReason.type")},
{prop: "request header 'Accept-Encoding'", exp: string(exp.Request.Headers["Accept-Encoding"]), got: getString(event, "request.headers.Accept-Encoding")},
{prop: "request HTTP method", exp: string(exp.Request.HTTPMethod), got: getString(event, "request.httpMethod")},
{prop: "request URL", exp: string(exp.Request.URL), got: getString(event, "request.url")},
} {
if tc.got != tc.exp {
t.Errorf("Wrong %s: expected '%v' but got '%v'", tc.prop, tc.exp, tc.got)
}
}
}
func assertValidSession(t *testing.T, event *simplejson.Json, unhandled bool) {
if sessionID := getString(event, "session.id"); len(sessionID) != 36 {
t.Errorf("Expected a valid session ID to be set but was '%s'", sessionID)
}
if _, e := time.Parse(time.RFC3339, getString(event, "session.startedAt")); e != nil {
t.Error(e)
}
expHandled, expUnhandled := 1, 0
if unhandled {
expHandled, expUnhandled = expUnhandled, expHandled
}
if got := getInt(event, "session.events.unhandled"); got != expUnhandled {
t.Errorf("Expected %d unhandled events in session but was %d", expUnhandled, got)
}
if got := getInt(event, "session.events.handled"); got != expHandled {
t.Errorf("Expected %d handled events in session but was %d", expHandled, got)
}
}
func verifyExistsInStackTrace(t *testing.T, exception *simplejson.Json, exp *StackFrame) {
isFile := func(frame *simplejson.Json) bool { return strings.HasSuffix(getString(frame, "file"), exp.File) }
isMethod := func(frame *simplejson.Json) bool { return getString(frame, "method") == exp.Method }
isLineNumber := func(frame *simplejson.Json) bool { return getInt(frame, "lineNumber") == exp.LineNumber }
arr, _ := exception.Get("stacktrace").Array()
for i := 0; i < len(arr); i++ {
frame := getIndex(exception, "stacktrace", i)
if isFile(frame) && isMethod(frame) && isLineNumber(frame) {
return
}
}
t.Errorf("Could not find expected stackframe %v in exception '%v'", exp, exception)
}