From f161630cf63f5c5f1e0fc2ba47ffb104149db66b Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Sat, 31 Dec 2022 09:43:13 +0300 Subject: [PATCH] [#6] services/util: Do not panic in sign function Signed-off-by: Evgenii Stratonikov --- pkg/services/util/sign.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/services/util/sign.go b/pkg/services/util/sign.go index 78f56607f3..2c2a5b83c4 100644 --- a/pkg/services/util/sign.go +++ b/pkg/services/util/sign.go @@ -47,16 +47,10 @@ func (s *SignService) SignResponse(statusSupported bool, resp ResponseMessage, e err = signature.SignServiceMessage(s.key, resp) if err != nil { - err = fmt.Errorf("could not sign response: %w", err) - - if statusSupported { - // We can't pass this error as status code since response will be unsigned. - // Isn't expected in practice, so panic is ok here. - panic(err) - } + return fmt.Errorf("could not sign response: %w", err) } - return err + return nil } func (s *SignService) VerifyRequest(req RequestMessage) error {