Set playmode - error handling, wrong parameter SHFFLE
hklages opened this issue ยท comments
In case of an invalid parameter (e.g. SHFFLE instead of SHUFFLE) the error handling is not straight forward.
Expected Behavior
Your standard example code console.log('xxxxxxx %j', playmode)
does NOT provide any information.
What works is: console.log('xxxxxxxx ' + JSON.stringify(playmode, Object.getOwnPropertyNames(playmode)))
Furthermore, I would expect that errors can be caught with "catch" clause.
Current Behavior
Error (invalid parameter) has to be handled in .then clause and with getOwnPropertyNames.
Possible Solution
Either: provide example see above
Or: change return method - maybe return Promise.Reject .... ?
Sample code or executed example
function labTest (node, msg, sonosPlayer) {
sonosPlayer.setPlayMode('SHFFLE') // invalid parameter
// .then(playmode => { console.log('result %j', playmode); }) // does not work
.then(playmode => { console.log('result' + JSON.stringify(playmode, Object.getOwnPropertyNames(playmode))); })
.catch(err => { console.log('Error occurred %j', err); });
}
Versions (and Environment)
Node version:
node-sonos version: 0.19
OS: debian (raspberry 4)
๐ This issue has been resolved in version 1.12.5 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐
Iโve changed it to throw the error instead of returning the error (my mistake). It now throws and error that the inputted mode is incorrect, with the allowed play modes in the message.