MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ExampleErrorContext

Function ExampleErrorContext

pkg/errorcontext/errorcontext_test.go:30–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28var err error
29
30func ExampleErrorContext() {
31 ctx, cancel := errorcontext.New(test.Context())
32 defer cancel(nil)
33
34 go func() {
35 for {
36 // do work
37 if err != nil {
38 cancel(err)
39 }
40 }
41 }()
42
43 for {
44 select {
45 // case data := <-dataChan:
46 case <-ctx.Done():
47 return
48 }
49 }
50}
51
52func TestErrorContext(t *testing.T) {
53 a := assertions.New(t)

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
ContextFunction · 0.92
DoneMethod · 0.80

Tested by

no test coverage detected