try

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilValue = errors.New("err: nil value")

ErrNilValue indicate both co-value and err are nil

Functions

func Catch

func Catch(errRef *error)

func CatchFunc

func CatchFunc(fn func(e *Error))

func Errorf added in v0.4.0

func Errorf(format string, args ...any) error

func HandleNillable added in v0.3.0

func HandleNillable[T any](val *T, err error) (*T, error)

HandleNillable process cornor case of error handling. Patch fucking stupid lang design.

  1. if err is not nil, return val & err
  2. if val is nil, return nil & ErrNilValue
  3. return val & nil

func Try

func Try(err error)

func Try1

func Try1[A any](a A, err error) A

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents an error that occurred during a Try operation.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Frame

func (e *Error) Frame() runtime.Frame

Frame returns the frame of the caller of the function that called Try.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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