diff --git a/lib/factory/cluster.go b/lib/factory/cluster.go index 5b23cddb..8661d3a2 100644 --- a/lib/factory/cluster.go +++ b/lib/factory/cluster.go @@ -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)] diff --git a/lib/factory/factory.go b/lib/factory/factory.go index 47132cff..0c049dbc 100644 --- a/lib/factory/factory.go +++ b/lib/factory/factory.go @@ -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 { @@ -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) }