gormtranserror

package
v0.0.0-...-ae1f611 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(src, dst error) bool

func NewError

func NewError(db *gorm.DB, ori error, text string) error

Types

type Column

type Column struct {
	Table  string
	Column string
}

type Error

type Error map[error]error

type ErrorPlugin

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

func (*ErrorPlugin) DuplicatedKey

func (ep *ErrorPlugin) DuplicatedKey(db *gorm.DB, err *mysql.MySQLError) error

DuplicatedKey 处理唯一索引错误

func (*ErrorPlugin) ForeignKey

func (ep *ErrorPlugin) ForeignKey(db *gorm.DB, err *mysql.MySQLError, isCreate bool) error

ForeignKey 处理创建引用错误

func (*ErrorPlugin) Initialize

func (ep *ErrorPlugin) Initialize(db *gorm.DB) error

func (*ErrorPlugin) Name

func (ep *ErrorPlugin) Name() string

func (*ErrorPlugin) Register

func (ep *ErrorPlugin) Register(object TableComment)

Register 从外部注册

func (*ErrorPlugin) Transform

func (ep *ErrorPlugin) Transform(db *gorm.DB)

type ForeignError

type ForeignError struct {
	Foreign    Column
	References Column
}

type GormError

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

func (*GormError) Error

func (ge *GormError) Error() string

type GormErrorPlugin

type GormErrorPlugin interface {
	Name() string
	Initialize(*gorm.DB) error
	Register(object TableComment)
	// contains filtered or unexported methods
}

func NewGlobalGormErrorPlugin

func NewGlobalGormErrorPlugin(opts ...Option) GormErrorPlugin

func NewGormErrorPlugin

func NewGormErrorPlugin(opts ...Option) GormErrorPlugin

type Info

type Info struct {
	Name    string          `json:"name"`
	Comment string          `json:"comment"`
	Column  map[string]Info `json:"-" gorm:"-"`
}

type Option

type Option func(o *options)

func WithAddForeignKeyFormat

func WithAddForeignKeyFormat(fm string) Option

func WithDelForeignKeyFormat

func WithDelForeignKeyFormat(fm string) Option

func WithDuplicatedKeyFormat

func WithDuplicatedKeyFormat(fm string) Option

func WithEnableLoad

func WithEnableLoad() Option

func WithError

func WithError(es map[error]error) Option

func WithGorm

func WithGorm(db *gorm.DB) Option

type TableComment

type TableComment interface {
	Comment() string
}

Jump to

Keyboard shortcuts

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