AMQP: improve error handling of UUID extraction from message content #31

This commit is contained in:
Sonja Happ 2019-11-21 13:03:36 +01:00
parent abb35ccfd9
commit 33d50a148d

View file

@ -122,7 +122,11 @@ func ConnectAMQP(uri string) error {
var sToBeUpdated database.Simulator var sToBeUpdated database.Simulator
db := database.GetDB() db := database.GetDB()
err = db.Where("UUID = ?", gjson.Get(content, "properties.uuid")).Find(sToBeUpdated).Error simulatorUUID := gjson.Get(content, "properties.uuid").String()
if simulatorUUID == "" {
log.Println("AMQP: Could not extract UUID of simulator from content of received message, SIMULATOR NOT UPDATED")
} else {
err = db.Where("UUID = ?", simulatorUUID).Find(sToBeUpdated).Error
if err != nil { if err != nil {
log.Println("AMQP: Unable to find simulator with UUID: ", gjson.Get(content, "properties.uuid"), " DB error message: ", err) log.Println("AMQP: Unable to find simulator with UUID: ", gjson.Get(content, "properties.uuid"), " DB error message: ", err)
} }
@ -141,6 +145,7 @@ func ConnectAMQP(uri string) error {
log.Println("AMQP: Updated simulator with UUID ", gjson.Get(content, "properties.uuid")) log.Println("AMQP: Updated simulator with UUID ", gjson.Get(content, "properties.uuid"))
} }
}
}() }()
return nil return nil