From 954a867bb783fe46b942ad9ba8088ad2254a3edf Mon Sep 17 00:00:00 2001
From: Fabian Seidl <fabian.b.seidl@stud.h-da.de>
Date: Fri, 8 Jul 2022 08:05:20 +0200
Subject: [PATCH] added missing error handling

---
 controller/eventService/Service.go  | 5 ++++-
 controller/nucleus/deviceWatcher.go | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/controller/eventService/Service.go b/controller/eventService/Service.go
index 5c13102d4..833ef9977 100644
--- a/controller/eventService/Service.go
+++ b/controller/eventService/Service.go
@@ -10,6 +10,7 @@ import (
 	interfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/event"
 
 	amqp "github.com/rabbitmq/amqp091-go"
+	"github.com/sirupsen/logrus"
 )
 
 // EventService is used to setup a connection to a broker and publish events to topics.
@@ -78,5 +79,7 @@ func (e *EventService) PublishEvent(topic string, event event.Event) error {
 
 // CloseConnection closes an exisiting connection.
 func (e *EventService) CloseConnection() {
-	e.connection.Close()
+	if err := e.connection.Close(); err != nil {
+		logrus.Error(err)
+	}
 }
diff --git a/controller/nucleus/deviceWatcher.go b/controller/nucleus/deviceWatcher.go
index 8eb0bb7a5..5f07e1613 100644
--- a/controller/nucleus/deviceWatcher.go
+++ b/controller/nucleus/deviceWatcher.go
@@ -9,6 +9,7 @@ import (
 	"code.fbi.h-da.de/danet/gosdn/controller/nucleus/types"
 	"code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi"
 	gpb "github.com/openconfig/gnmi/proto/gnmi"
+	"github.com/sirupsen/logrus"
 	log "github.com/sirupsen/logrus"
 )
 
@@ -62,7 +63,9 @@ func (d *DeviceWatcher) callSubscribe(device device.Device, opts *gnmi.Subscribe
 	ctx := context.Background()
 	ctx = context.WithValue(ctx, types.CtxKeyOpts, opts)
 
-	device.Transport().SubscribeInternal(ctx, handleSubscribeRepsonse)
+	if err := device.Transport().SubscribeInternal(ctx, handleSubscribeRepsonse); err != nil {
+		logrus.Error(err)
+	}
 }
 
 func handleSubscribeRepsonse(resp *gpb.SubscribeResponse) {
-- 
GitLab