mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 04:10:34 +00:00
MG-167 - Terminate Alarms message which failed to handle (#191)
* initial implementation Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * update tests Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * update postgres writer Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * fix readers tests Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * address comments Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * fix senML naming Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * remove logger from service Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * fix failing linter Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * terminate message when alarm fails to decode Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * revert changes Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * remove message from logging Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * remove empty line Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * wrap error Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> --------- Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
This commit is contained in:
@@ -15,6 +15,8 @@ import (
|
||||
"github.com/absmach/supermq/pkg/messaging"
|
||||
)
|
||||
|
||||
var errFailedToDecode = errors.New("failed to decode alarm")
|
||||
|
||||
type handler struct {
|
||||
svc alarms.Service
|
||||
logger *slog.Logger
|
||||
@@ -34,7 +36,7 @@ func (h handler) Handle(msg *messaging.Message) (err error) {
|
||||
|
||||
var alarm alarms.Alarm
|
||||
if err := gob.NewDecoder(bytes.NewReader(msg.GetPayload())).Decode(&alarm); err != nil {
|
||||
return err
|
||||
return messaging.NewError(errors.Wrap(errFailedToDecode, err), messaging.Term)
|
||||
}
|
||||
alarm.DomainID = msg.GetDomain()
|
||||
alarm.ChannelID = msg.GetChannel()
|
||||
|
||||
Reference in New Issue
Block a user