opc icon indicating copy to clipboard operation
opc copied to clipboard

Add function to return real error from OPC DA

Open DanielXavierJob opened this issue 1 year ago • 2 comments

Hello! I need to get the real OPC DA connection error, as well as other errors, but in the current logic of the code you just check the error and return a pre-formatted string saying, for example, that the connection failed, and I believe that the return informs if was the problem with the machine or was it with the server, was it between communication and other important factors for debuggin

Ex:

image

DanielXavierJob avatar Dec 17 '24 15:12 DanielXavierJob

I did a test and just added this to the failed connection line of code: return nil, errors.New(fmt.Sprintf("Connection failed %v", err.Error()))

And the feedback was very good: image

DanielXavierJob avatar Dec 17 '24 15:12 DanielXavierJob

Yes, that's a good idea. Would you like to submit your changes as a PR?

If so, please create the errors with fmt.Errorf("Connection failed: %w", err) and also update the logger output.

konimarti avatar Dec 17 '24 15:12 konimarti