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

Misleading errors. The error detection process and the error message text should be improved to provide more informative details about the error's origin and its description. #11

Open
OKhalkov opened this issue Jun 7, 2023 · 0 comments

Comments

@OKhalkov
Copy link

OKhalkov commented Jun 7, 2023

Example 1:
The error is in line 9; there is a missing ';' at the end. However, the error message incorrectly states that the issue is in line 10.
image

 /** Decoder **/

 // decode payload to string
 var payloadStr = decodeToString(payload);

 // decode payload to JSON
 // var data = decodeToJson(payload);

 var deviceName = payloadStr.substring(0,6)
 var deviceType = payloadStr.substring(6,13);

 // Result object with device/asset attributes/telemetry data
 var result = {
     deviceName: deviceName,
     deviceType: deviceType,
     attributes: {},
     telemetry: {
         temperature: parseFloat(payloadStr.substring(13, 17))
     }
 };

 /** Helper functions 'decodeToString' and 'decodeToJson' are already built-in **/
 
 return result;

Example 2:
The issue is in line 8, where a non-existing method is being called. However, the error message incorrectly states that the problem is in the first line.
image

/** Decoder **/

// decode payload to string 
var payload= decodeToJson(payload);

var deviceName = payload["devName"];
var deviceType = payload.param1;
var param2 = payload.param2.someNonExistingMethod();

// Result object with device/asset attributes/telemetry data 
var result = {
    deviceName: deviceName,
    deviceType: deviceType,
    attributes: {},
    telemetry: {
        temperature: payload.param1,
        temp: payload["param2"].test,
        t: param2
    }
};

/** Helper functions 'decodeToString' and 'decodeToJson' are already built-in **/

return result;
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

No branches or pull requests

1 participant