[#1156] ape: Return not found when removing local overrides

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-06-04 18:27:37 +03:00 committed by Evgenii Stratonikov
parent a849236b68
commit a90310335d

View file

@ -174,10 +174,8 @@ func (s *Server) RemoveChainLocalOverride(_ context.Context, req *control.Remove
return nil, err return nil, err
} }
if err = s.localOverrideStorage.LocalStorage().RemoveOverride(apechain.Ingress, target, apechain.ID(req.GetBody().GetChainId())); err != nil { if err = s.localOverrideStorage.LocalStorage().RemoveOverride(apechain.Ingress, target, req.GetBody().GetChainId()); err != nil {
if code := getCodeByLocalStorageErr(err); code != codes.NotFound { return nil, status.Error(getCodeByLocalStorageErr(err), err.Error())
return nil, status.Error(code, err.Error())
}
} }
resp := &control.RemoveChainLocalOverrideResponse{ resp := &control.RemoveChainLocalOverrideResponse{
Body: &control.RemoveChainLocalOverrideResponse_Body{}, 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 err = s.localOverrideStorage.LocalStorage().RemoveOverridesByTarget(apechain.Ingress, target); err != nil {
if code := getCodeByLocalStorageErr(err); code != codes.NotFound { return nil, status.Error(getCodeByLocalStorageErr(err), err.Error())
return nil, status.Error(code, err.Error())
}
} }
resp := &control.RemoveChainLocalOverridesByTargetResponse{ resp := &control.RemoveChainLocalOverridesByTargetResponse{
Body: &control.RemoveChainLocalOverridesByTargetResponse_Body{}, Body: &control.RemoveChainLocalOverridesByTargetResponse_Body{},
@ -246,7 +242,8 @@ func (s *Server) ListTargetsLocalOverrides(_ context.Context, req *control.ListT
} }
func getCodeByLocalStorageErr(err error) codes.Code { 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.NotFound
} }
return codes.Internal return codes.Internal