3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
14 func try[T any](v T, err error) T {
21 func handle(handle func(error)) {
22 if issue := recover(); issue != nil {
23 if e, ok := issue.(error); ok && e != nil {
26 handle(fmt.Errorf("%v", e))
32 defer handle(func(e error) { log.Fatalln(e) })
33 _ = try(fmt.Print(""))