Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log an error in applyPreset if room in list cannot be found with tests #123

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/prototypes/SonosSystem/applyPreset.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ function applyPreset(preset) {
let coordinator;

promise = promise.then(() => {
players = preset.players.map(playerInfo => this.getPlayer(playerInfo.roomName));
players = preset.players.map(playerInfo => {
const result = this.getPlayer(playerInfo.roomName);
if (!result) {
logger.error(`preset ${preset.favorite}: bad room name ${playerInfo.roomName}`);
}
// it will be undefined which results in an error later. We filter it below
// so that the bad or missing room is ignored and the other players work.
return result;
}).filter(player => player !== undefined);
});

promise = promise.then(() => {
Expand Down