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

Function ExampleTryUnwrap

xerror/xerror_example_test.go:141–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139}
140
141func ExampleTryUnwrap() {
142 result1 := TryUnwrap(strconv.Atoi("42"))
143 fmt.Println(result1)
144
145 _, err := strconv.Atoi("4o2")
146 defer func() {
147 v := recover()
148 result2 := reflect.DeepEqual(err.Error(), v.(*strconv.NumError).Error())
149 fmt.Println(result2)
150 }()
151
152 TryUnwrap(strconv.Atoi("4o2"))
153
154 // Output:
155 // 42
156 // true
157}
158
159func ExampleTryCatch() {
160 calledFinally := false

Callers

nothing calls this directly

Calls 2

TryUnwrapFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…