You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/05/16 15:09:21 UTC
[plc4x] branch develop updated: fix(plc4go/spi): gracefully handle tag names not found.
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new c240ade351 fix(plc4go/spi): gracefully handle tag names not found.
c240ade351 is described below
commit c240ade351764503a3373b073dd8893857642f36
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue May 16 17:09:13 2023 +0200
fix(plc4go/spi): gracefully handle tag names not found.
---
plc4go/spi/model/DefaultPlcSubscriptionResponse.go | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/plc4go/spi/model/DefaultPlcSubscriptionResponse.go b/plc4go/spi/model/DefaultPlcSubscriptionResponse.go
index 7b8a8c0fdc..72c9dd4102 100644
--- a/plc4go/spi/model/DefaultPlcSubscriptionResponse.go
+++ b/plc4go/spi/model/DefaultPlcSubscriptionResponse.go
@@ -79,14 +79,22 @@ func (d *DefaultPlcSubscriptionResponse) GetTagNames() []string {
}
func (d *DefaultPlcSubscriptionResponse) GetResponseCode(name string) apiModel.PlcResponseCode {
- return d.values[name].GetCode()
+ item, ok := d.values[name]
+ if !ok {
+ return apiModel.PlcResponseCode_NOT_FOUND
+ }
+ return item.GetCode()
}
func (d *DefaultPlcSubscriptionResponse) GetSubscriptionHandle(name string) (apiModel.PlcSubscriptionHandle, error) {
- if d.values[name].GetCode() != apiModel.PlcResponseCode_OK {
+ item, ok := d.values[name]
+ if !ok {
+ return nil, errors.Errorf("item for %s not found", name)
+ }
+ if item.GetCode() != apiModel.PlcResponseCode_OK {
return nil, errors.Errorf("%s failed to subscribe", name)
}
- return d.values[name].GetSubscriptionHandle(), nil
+ return item.GetSubscriptionHandle(), nil
}
func (d *DefaultPlcSubscriptionResponse) GetSubscriptionHandles() []apiModel.PlcSubscriptionHandle {