sqlex

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScopeTx

func ScopeTx(ctx context.Context, db BeginTx, fn func(*sql.Tx) error) (err error)

func Throw

func Throw(ex Exception)

Throw raise panic with exception

Types

type BeginTx

type BeginTx interface {
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

type Block

type Block struct {
	Try     func()
	Catch   func(error)
	Finally func()
}
Block {
	Try: func() {
		fmt.Println("Try..")
		Throw("stop it")
	},
	Catch: func(e Exception) {
		fmt.Printf("Caught %v\n", e)
	},
	Finally: func() {
		fmt.Println("Finally..")
	},
}.Do()

Block Try-Catch-Finally block struct

func (Block) Do

func (b Block) Do()

Do run block state

type Exception

type Exception interface{}

Exception pass exception to Catch

Jump to

Keyboard shortcuts

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