[#1156] ape: Return not found when removing local overrides
All checks were successful
DCO action / DCO (pull_request) Successful in 8m4s
Build / Build Components (1.21) (pull_request) Successful in 9m45s
Vulncheck / Vulncheck (pull_request) Successful in 9m20s
Build / Build Components (1.22) (pull_request) Successful in 14m16s
Pre-commit hooks / Pre-commit (pull_request) Successful in 22m34s
Tests and linters / gopls check (pull_request) Successful in 7m10s
Tests and linters / Staticcheck (pull_request) Successful in 7m22s
Tests and linters / Lint (pull_request) Successful in 8m21s
Tests and linters / Tests (1.21) (pull_request) Successful in 11m53s
Tests and linters / Tests (1.22) (pull_request) Successful in 11m54s
Tests and linters / Tests with -race (pull_request) Successful in 12m14s

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-06-04 18:27:37 +03:00
parent 8fcd0f8f8d
commit e55cddead3

View file

@ -174,10 +174,8 @@ func (s *Server) RemoveChainLocalOverride(_ context.Context, req *control.Remove
return nil, err
}
if err = s.localOverrideStorage.LocalStorage().RemoveOverride(apechain.Ingress, target, apechain.ID(req.GetBody().GetChainId())); err != nil {
if code := getCodeByLocalStorageErr(err); code != codes.NotFound {
return nil, status.Error(code, err.Error())
}
if err = s.localOverrideStorage.LocalStorage().RemoveOverride(apechain.Ingress, target, req.GetBody().GetChainId()); err != nil {
return nil, status.Error(getCodeByLocalStorageErr(err), err.Error())
}
resp := &control.RemoveChainLocalOverrideResponse{
Body: &control.RemoveChainLocalOverrideResponse_Body{},
@ -200,9 +198,7 @@ func (s *Server) RemoveChainLocalOverridesByTarget(_ context.Context, req *contr
}
if err = s.localOverrideStorage.LocalStorage().RemoveOverridesByTarget(apechain.Ingress, target); err != nil {
if code := getCodeByLocalStorageErr(err); code != codes.NotFound {
return nil, status.Error(code, err.Error())
}
return nil, status.Error(getCodeByLocalStorageErr(err), err.Error())
}
resp := &control.RemoveChainLocalOverridesByTargetResponse{
Body: &control.RemoveChainLocalOverridesByTargetResponse_Body{},
@ -246,7 +242,8 @@ func (s *Server) ListTargetsLocalOverrides(_ context.Context, req *control.ListT
}
func getCodeByLocalStorageErr(err error) codes.Code {
if errors.Is(err, engine.ErrChainNotFound) || errors.Is(err, engine.ErrChainNameNotFound) {
if errors.Is(err, engine.ErrChainNotFound) || errors.Is(err, engine.ErrChainNameNotFound) ||
errors.Is(err, engine.ErrResourceNotFound) {
return codes.NotFound
}
return codes.Internal