Browse Source

优化行为

yjp 1 year ago
parent
commit
be386fbc68
1 changed files with 8 additions and 2 deletions
  1. 8 2
      mqtt_binding/request/request.go

+ 8 - 2
mqtt_binding/request/request.go

@@ -2,9 +2,11 @@ package request
 
 import (
 	"encoding/json"
+	"errors"
 	"git.sxidc.com/go-tools/api_binding/mqtt_binding/mqtt_client"
 	"git.sxidc.com/go-tools/api_binding/mqtt_binding/mqtt_client/router"
 	"git.sxidc.com/go-tools/api_binding/mqtt_binding/response"
+	"git.sxidc.com/service-supports/fslog"
 	"github.com/go-playground/validator/v10"
 )
 
@@ -25,12 +27,16 @@ func BindingJson[O any](c *mqtt_client.MqttClient, item *router.Item, request an
 		if responseIdentifier != nil {
 			err := json.Unmarshal(data, responseIdentifier)
 			if err != nil {
-				panic(err)
+				err := errors.New("Topic: " + item.Topic + " Response Identifier Unmarshal Error: " + err.Error())
+				fslog.Error(err)
+				return false
 			}
 
 			err = validate.Struct(responseIdentifier)
 			if err != nil {
-				panic(err)
+				err := errors.New("Topic: " + item.Topic + " Response Identifier Validate Error: " + err.Error())
+				fslog.Error(err)
+				return false
 			}
 		}