[#1693] services: Replace conditional panics with asserts

Change-Id: Ic79609e6ad867caa88ad245b3014aa7fc32e05a8
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
Ekaterina Lebedeva 2025-04-08 16:54:05 +03:00
parent fc6abe30b8
commit bc045b29e2
4 changed files with 14 additions and 13 deletions

View file

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/assert"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/version"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util/response"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap"
@ -46,10 +47,12 @@ type NetworkInfo interface {
}
func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo, respSvc *response.Service) Server {
if s == nil || netInfo == nil || !version.IsValid(v) || respSvc == nil {
// this should never happen, otherwise it programmers bug
panic("can't create netmap execution service")
}
// this should never happen, otherwise it's a programmer's bug
msg := "BUG: can't create netmap execution service"
assert.False(s == nil, msg, "node state is nil")
assert.False(netInfo == nil, msg, "network info is nil")
assert.False(respSvc == nil, msg, "response service is nil")
assert.True(version.IsValid(v), msg, "invalid version")
res := &executorSvc{
state: s,