Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Jun 25, 2022
1 parent b0e36d1 commit 4247b6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/factory/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Cluster struct {
func (c *Cluster) Master() (r db.Database) {
length := len(c.masters)
if length == 0 {
panic(`Not connected to any database`)
panic(ErrNotConnectedAnyDatabase)
}
if length > 1 {
r = c.masters[c.masterSelecter.Select(length)]
Expand Down
9 changes: 5 additions & 4 deletions lib/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
)

var (
ErrNotFoundKey = errors.New(`not found the key`)
ErrNotFoundTable = errors.New(`not found the table`)
ErrNotFoundField = errors.New(`not found the field`)
ErrNotFoundKey = errors.New(`not found the key`)
ErrNotFoundTable = errors.New(`not found the table`)
ErrNotFoundField = errors.New(`not found the field`)
ErrNotConnectedAnyDatabase = errors.New(`not connected to any database`)
)

func New() *Factory {
Expand Down Expand Up @@ -151,7 +152,7 @@ func (f *Factory) Cluster(index int) *Cluster {
return f.databases[index]
}
if index == 0 {
panic(`Not connected to any database`)
panic(ErrNotConnectedAnyDatabase)
}
return f.Cluster(0)
}
Expand Down

0 comments on commit 4247b6a

Please sign in to comment.