@@ -22,10 +22,16 @@ type rangeSpec struct {
2222
2323const splitParts = 2
2424
25+ var (
26+ ErrAddressRequired = errors .New ("address is required" )
27+ ErrNoRaftGroupsConfigured = errors .New ("no raft groups configured" )
28+ ErrNoShardRangesConfigured = errors .New ("no shard ranges configured" )
29+ )
30+
2531func parseRaftGroups (raw , defaultAddr string ) ([]groupSpec , error ) {
2632 if raw == "" {
2733 if defaultAddr == "" {
28- return nil , errors . New ( "address is required" )
34+ return nil , ErrAddressRequired
2935 }
3036 return []groupSpec {{id : 1 , address : defaultAddr }}, nil
3137 }
@@ -56,7 +62,7 @@ func parseRaftGroups(raw, defaultAddr string) ([]groupSpec, error) {
5662 groups = append (groups , groupSpec {id : id , address : addr })
5763 }
5864 if len (groups ) == 0 {
59- return nil , errors . New ( "no raft groups configured" )
65+ return nil , ErrNoRaftGroupsConfigured
6066 }
6167 return groups , nil
6268}
@@ -93,7 +99,7 @@ func parseShardRanges(raw string, defaultGroup uint64) ([]rangeSpec, error) {
9399 ranges = append (ranges , rangeSpec {start : start , end : end , groupID : groupID })
94100 }
95101 if len (ranges ) == 0 {
96- return nil , errors . New ( "no shard ranges configured" )
102+ return nil , ErrNoShardRangesConfigured
97103 }
98104 return ranges , nil
99105}
0 commit comments