Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modbus: AbstractReadTask: Enhance Parsing Response; exception catch #2879

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DerStoecki
Copy link
Contributor

More generic catch block for more detailed channel assignment errors. E.g. the original code is not able to catch the following kind of errors:

[modbus1 ] ERROR [dbus.api.task.AbstractReadTask] Parsing Response failed. 
IllegalArgumentException: Unable to set value [-4395165653183430656] for Channel [battery0/ChrW]: 
Cannot convert. Long [-4395165653183430656] is not fitting in Integer range. 

This kind of messages would have been very helpful for detecting channel mapping errors, but it is not catched by OpenemsException

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2879      +/-   ##
=============================================
+ Coverage      57.31%   57.34%   +0.03%     
- Complexity      9156     9163       +7     
=============================================
  Files           2177     2177              
  Lines          92873    92873              
  Branches        6883     6883              
=============================================
+ Hits           53221    53245      +24     
+ Misses         37701    37680      -21     
+ Partials        1951     1948       -3     
---- 🚨 Try these New Features:

@clehne
Copy link
Contributor

clehne commented Nov 19, 2024

@DerStoecki Could you please add an appropriate Junit Testcase, so that Codecov runs through.

clehne and others added 2 commits November 20, 2024 12:39
More generic catch block for more detailed channel assignment errors. E.g. the original code is not able to catch the following kind of errors:
[modbus1 ] ERROR [dbus.api.task.AbstractReadTask] Parsing Response failed. IllegalArgumentException: Unable to set value [-4395165653183430656] for Channel [battery0/ChrW]: Cannot convert. Long [-4395165653183430656] is not fitting in Integer range.

This kind of messages would have been very helpful for detecting channel mapping errors, but it is not catched by OpenemsException
Trigger IllegalArgumentException by adding a new Channel, and filling it with Integer.MAX value (not fitting in short range), catch the log and check for "IllegalArgumentException"
-> For me : easiest way to catch the logError
@DerStoecki DerStoecki force-pushed the feature/ModbusTaskGenericExceptionCatch branch from 0547606 to 10d2953 Compare November 20, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants