proxy.golang.org : github.com/dsnet/try : v0.0.1
Package try emulates aspects of the ill-fated "try" proposal using generics. See https://golang.org/issue/32437 for inspiration. Example usage: This package is a sharp tool and should be used with care. Quick and easy error handling can occlude critical error handling logic. Panic handling generally should not cross package boundaries or be an explicit part of an API. Package try is a good fit for short Go programs and unit tests where development speed is a greater priority than reliability. Since the E functions panic if an error is encountered, recovering in such programs is optional. Code before try: Code after try: The E family of functions all remove a final error return, panicking if non-nil. Handle recovers from that panic and allows assignment of the error to a return error value. Other panics are not recovered. HandleF is like Handle, but it calls a function after any such assignment. F wraps an error with file and line information and calls a function on error. It inter-operates well with testing.TB and log.Fatal. Recover is like F, but it supports more complicated error handling by passing the error and runtime frame directly to a function.
Registry -
Documentation -
Download -
JSON
purl: pkg:golang/github.com/dsnet/[email protected]
Published:
Indexed: