Open Trikolon opened 8 years ago
The try-catch block in function temperature() covers its callback. This way the library catches all exceptions thrown in the callback, even unrelated ones from applications using the library, and causes it to fail.
https://github.com/chamerling/ds18b20/blob/6a8e71af54feea22edcac9945a38e615525d40da/lib/ds18b20.js#L85
ds18b20.temperature(id, (error, value) => { throw new Error("Custom error unrelated to ds18b20"); }
Output: ERROR: Can not read temperature for sensor XY
ERROR: Can not read temperature for sensor XY
The try-catch block should only catch exceptions from parseData() instead.
The PR for this bug fixed the same issue for me.
Going to take some time to check this and refactor the module. Thx for the reminder here ;)
The try-catch block in function temperature() covers its callback. This way the library catches all exceptions thrown in the callback, even unrelated ones from applications using the library, and causes it to fail.
https://github.com/chamerling/ds18b20/blob/6a8e71af54feea22edcac9945a38e615525d40da/lib/ds18b20.js#L85
Example:
Output:
ERROR: Can not read temperature for sensor XY
The try-catch block should only catch exceptions from parseData() instead.