Commit 95579e39 authored by Andreas Heimann's avatar Andreas Heimann

added error handling

parent cc3e18b9
...@@ -20,33 +20,42 @@ function SongDetailLoad(songId) { ...@@ -20,33 +20,42 @@ function SongDetailLoad(songId) {
DOMSongDetail.classList.remove("active"); DOMSongDetail.classList.remove("active");
DOMSongDetailActions.classList.remove("active"); DOMSongDetailActions.classList.remove("active");
api.getSongDetail(songId).then(function(songData) { api.getSongDetail(songId).then(function(apiResponse) {
DOMSongDetail.classList.add("active"); let songData = apiResponse.data;
DOMSongDetailActions.classList.add("active");
DOMSongDetailBackground.style.backgroundImage = "url('" + songData.paths.cover + "')"; if(apiResponse.status == 404) {
DOMSongDetailCover.style.backgroundImage = "url('" + songData.paths.cover + "')"; NavigateToSection(6);
} else {
DOMSongDetail.classList.add("active");
DOMSongDetailActions.classList.add("active");
DOMSongTitle.innerText = songData.title; DOMSongDetailBackground.style.backgroundImage = "url('" + songData.paths.cover + "')";
DOMSongSubtitle.innerText = songData.subtitle; DOMSongDetailCover.style.backgroundImage = "url('" + songData.paths.cover + "')";
DOMSongArtist.innerText = songData.artist;
DOMSongCharter.innerText = songData.charter;
DOMButtonPreview.innerText = "PLAY PREVIEW"; DOMSongTitle.innerText = songData.title;
DOMSongSubtitle.innerText = songData.subtitle;
DOMSongArtist.innerText = songData.artist;
DOMSongCharter.innerText = songData.charter;
DOMSongTags.innerHTML = ""; DOMButtonPreview.innerText = "PLAY PREVIEW";
songData.tags.forEach(function(tag) {
if(tag != "") {
let newTag = document.createElement("div");
newTag.classList.add("tag");
newTag.innerText = tag;
DOMSongTags.appendChild(newTag); DOMSongTags.innerHTML = "";
} songData.tags.forEach(function(tag) {
}); if(tag != "") {
let newTag = document.createElement("div");
newTag.classList.add("tag");
newTag.innerText = tag;
DOMSongTags.appendChild(newTag);
}
});
}
currentSongId = songId; currentSongId = songId;
currentSongData = songData; currentSongData = songData;
}).catch(function(error) {
console.error(error);
NavigateToSection(5);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment