wschenk / tradfri-cli

cli scripts to control tradfri internet gateway
https://willschenk.com/articles/2019/controlling_ikea_tradfri_with_node
24 stars 3 forks source link

Behaviour of devices.js when no Tradfri gateway is found #2

Closed MDecker-MobileComputing closed 4 years ago

MDecker-MobileComputing commented 4 years ago

When upon running the command node devices.js no Tradfri gateway is found (e.g., because it is switched off), then the stack trace of an exception is written to the console:

Looking up IKEA Tradfri gateway on your network
(node:10990) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'host' of null
    at Object.getConnection (/home/michi/tradfri-cli/connection.js:13:41)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:10990) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10990) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This might confuse less experienced users, so it would be preferable when an error message like No Tradfri gateway found in local network would appear in this case.

wschenk commented 4 years ago

Great idea.

Pushed.