gfunc

package
v0.0.0-...-37ff87a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//SafetyCall call func f, and returned recover() error or nil
	SafetyCall = gerror.Try

	//SafetyCallError call func f, and wrap recover() error to gcore.Error, or nil returned
	SafetyCallError = gerror.TryWithStack

	//RecoverNop call recover() and do nothing
	RecoverNop = gerror.RecoverNop

	//RecoverNopAndFunc call recover() and then call the f
	RecoverNopAndFunc = gerror.RecoverNopFunc
)

Functions

func CatchCheckError

func CatchCheckError()

CatchCheckError catch the panic error throwing by CheckError. If func have another defer to catch recover(), put the defer before defer CatchCheckError. For example:

func myFunc() (err error) {
		defer func() {
			e := recover()
			if e != nil {
				err = fmt.Errorf("%s", e)
			}
		}()
		defer CatchCheckError()
		panic("abc")
	}

func CheckError

func CheckError(err error)

CheckError if err is not nil, the func call will return immediately at CheckError call. this should be worked with defer CatchCheckError()

func CheckError2

func CheckError2(v interface{}, err error) *gvalue.AnyValue

CheckError2 check the err and return the value if err is nil

func CheckError3

func CheckError3(v1 interface{}, v2 interface{}, err error) (*gvalue.AnyValue, *gvalue.AnyValue)

CheckError3 check the err and return the value if err is nil

func IsWaitTimeoutErr

func IsWaitTimeoutErr(e error) bool

func Recover

func Recover(f func(gcore.Error))

func Wait

func Wait(f func()) <-chan error

func WaitTimeout

func WaitTimeout(f func(), timeout time.Duration) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL