Skip to content

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

Description

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;

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions