Skip to content

try-catch too broad #9

@Trikolon

Description

@Trikolon

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.

return callback(new Error('Can not read temperature for sensor ' + sensor));

Example:

ds18b20.temperature(id, (error, value) => {
    throw new Error("Custom error unrelated to ds18b20");
}

Output:
ERROR: Can not read temperature for sensor XY

The try-catch block should only catch exceptions from parseData() instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions