Cloud-Automation / node-modbus

Modbus TCP Client/Server implementation for Node.JS
467 stars 174 forks source link

Improved UserRequestError message if error is ModbusException. #340

Closed Zandor300 closed 4 months ago

Zandor300 commented 5 months ago

If a UserRequestError is thrown because of a Modbus Exception, I added an improved message to the error.

Before it would just print out:

A Modbus Exception Occurred - See Response Body

console.error(..) would print out the response.body.code and using that could be seen what the issue is, but when I use the error in conjunction with Sentry error reporting, it won't provide me those values.

Now the error message will be something like:

ModbusException: ILLEGAL DATA ADDRESS (Code 2) (Device Address 1)

@stefanpoeter Could you take a look?

Zandor300 commented 4 months ago

@stefanpoeter Could you take a look at my PR?

stefanpoeter commented 4 months ago

Hi @Zandor300, sorry for the late reply and thank you very much for your contribution. Can you increase the patch number in the package.json. Then I approve it right away.

Zandor300 commented 4 months ago

@stefanpoeter I've changed the version from 4.0.10 to 40.0.11.