out of bound errot detection
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
eeb39338e2
commit
65f9ee2e07
@ -28,6 +28,9 @@ func (sl *ServerList) FilterByIdxs(MessageServerIdxs []int) (filtered *ServerLis
|
|||||||
|
|
||||||
// GetServerByIdx returns a server from it's index
|
// GetServerByIdx returns a server from it's index
|
||||||
func (sl *ServerList) GetServerByIdx(idx int) (server *Server, err error) {
|
func (sl *ServerList) GetServerByIdx(idx int) (server *Server, err error) {
|
||||||
|
if idx > len(sl.Servers)-1 {
|
||||||
|
return nil, errors.New("requested server out of range of defined message servers")
|
||||||
|
}
|
||||||
return &sl.Servers[idx], nil
|
return &sl.Servers[idx], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user