jywjyw commented on issue #1346:
URL: https://github.com/apache/plc4x/issues/1346#issuecomment-1907461143

   If a tag is invalid, calling "plcReadResponse.getObject('mytag')" will throw 
exception below:
   ```
   org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Tag 'bool-2' could 
not be fetched, response was INVALID_ADDRESS
   ```
   I think the code should be :
   ```
   public static Map<String, Object> convertPlcResponseToMap(PlcReadResponse 
plcReadResponse) {
           Map<String,Object> ret = new LinkedHashMap<>();
        for (String tagName : plcReadResponse.getTagNames()) {
                if(plcReadResponse.getResponseCode(tagName) == 
PlcResponseCode.OK) {
                        ret.put(tagName, plcReadResponse.getObject(tagName));
                }else {
                         ret.put(tagName, new 
Exception(plcReadResponse.getResponseCode(tagName).name()));      //should cast 
it to a special Exception
                }
        }
        return ret;
      }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to