try

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 0 Imported by: 5

README

Try-Finally-Catch

Usage

Quick usage

import "github.com/gflydev/core/try"

try.Perform(func() {
    calledTry()
}).Finally(func() {
    calledFinally()
}).Catch(func(e try.E) {
    log.Errorf("Catch error %v", e)
})

Documentation

Index

Constants

View Source
const RethrowPanic = "___throw_it___"

RethrowPanic Special re-throw panic

Variables

This section is empty.

Functions

func Throw

func Throw(e E)

Throw function (return or rethrow an exception)

Types

type E

type E interface{}

E Error type

type EF

type EF func(err E)

EF Error function type

type F

type F func()

F Function type

type It

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

It structure

func Perform

func Perform(funcToTry F) (o *It)

Perform register the main-logic function.

func (*It) Catch

func (o *It) Catch(funcCaught EF) *It

Catch register the finally-logic function.

func (*It) Finally

func (o *It) Finally(finallyFunc F) *It

Finally register the finally-logic function.

Jump to

Keyboard shortcuts

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