[#6] services/util: Do not panic in sign function

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2022-12-31 09:43:13 +03:00
parent cfd1b1d349
commit f161630cf6

View file

@ -47,16 +47,10 @@ func (s *SignService) SignResponse(statusSupported bool, resp ResponseMessage, e
err = signature.SignServiceMessage(s.key, resp) err = signature.SignServiceMessage(s.key, resp)
if err != nil { if err != nil {
err = fmt.Errorf("could not sign response: %w", err) return 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 err return nil
} }
func (s *SignService) VerifyRequest(req RequestMessage) error { func (s *SignService) VerifyRequest(req RequestMessage) error {