Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Player UI #7 - Show Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
theADAMJR committed Dec 15, 2020
1 parent e701e1f commit 7ac3419
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion dashboard/assets/js/music/html-music-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ class HTMLMusicWrapper {
#music;

set apiError(error) {
console.log(error);
if (!error)
return $('#musicAPIError').addClass('d-none');

$('#musicAPIError').removeClass('d-none');
$('#musicAPIError').text(error.message ?? 'Unknown error.');
}

constructor(musicClient) {
Expand Down
11 changes: 9 additions & 2 deletions dashboard/assets/js/music/music-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ class MusicWrapper {
return json;
} catch (error) {
this.#html.apiError = error;
throw error;
}
}

async play(query) {
await this.#fetch(`play?q=${query}`);
try {
await this.#fetch(`play?q=${query}`);
this.#html.apiError = null;
} catch {}
await this.updateList();
}

async stop() {
await this.#fetch(`stop`);
try {
await this.#fetch(`stop`);
this.#html.apiError = null;
} catch {}
await this.updateList();
}

Expand Down

0 comments on commit 7ac3419

Please sign in to comment.