MCPcopy
hub / github.com/duke-git/lancet / ExamplePromise_Catch

Function ExamplePromise_Catch

promise/promise_example_test.go:94–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func ExamplePromise_Catch() {
95 p1 := New(func(resolve func(string), reject func(error)) {
96 err := errors.New("error1")
97 reject(err)
98 })
99
100 p2 := p1.Catch(func(err error) error {
101 e := errors.New("error2")
102 return internal.JoinError(err, e)
103 })
104
105 _, err := p1.Await()
106
107 fmt.Println(err.Error())
108
109 result2, err := p2.Await()
110
111 fmt.Println(result2)
112 fmt.Println(err.Error())
113
114 // Output:
115 // error1
116 //
117 // error1
118 // error2
119}
120
121func ExampleAll() {
122 p1 := New(func(resolve func(string), reject func(error)) {

Callers

nothing calls this directly

Calls 6

JoinErrorFunction · 0.92
NewMethod · 0.80
AwaitMethod · 0.80
NewFunction · 0.70
CatchMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…