Skip to content

Commit

Permalink
Catch json parse exception in JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Dec 17, 2023
1 parent cc61ab1 commit 76dfff4
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/webapp/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -711,21 +711,28 @@ <h3 class="col text-muted">
handleImageData(data);
}
else {
var notificationEvent = JSON.parse(data);
if(notificationEvent != null && typeof(notificationEvent) == "object")
{
var eventType = notificationEvent.eventType;
if (eventType == "UPDATE_AUDIO_LEVEL") {
//
console.debug("Update audio level from server(max:0, min:127): " + notificationEvent.audioLevel);
var notificationEvent;
try {
notificationEvent = JSON.parse(data);
if(notificationEvent != null && typeof(notificationEvent) == "object")
{
var eventType = notificationEvent.eventType;
if (eventType == "UPDATE_AUDIO_LEVEL") {
//
console.debug("Update audio level from server(max:0, min:127): " + notificationEvent.audioLevel);
}
else {
$("#all-messages").append("Received: " + data + "<br>");
}
}
else {
$("#all-messages").append("Received: " + data + "<br>");
}
}
else {
catch (exception) {
$("#all-messages").append("Received: " + data + "<br>");
}

}
}
else if (info == "bitrateMeasurement") {
Expand Down

0 comments on commit 76dfff4

Please sign in to comment.