Catch json parse error for current activity

This commit is contained in:
JonnyWong16 2016-06-06 00:28:01 -07:00
parent 38116a14f3
commit 0d38b3de16

View file

@ -103,10 +103,20 @@
type: 'GET',
cache: false,
async: true,
error: function (xhr, status, error) {
console.log(status + ': ' + error);
},
complete: function (xhr, status) {
$('#dashboard-checking-activity').remove();
var current_activity = $.parseJSON(xhr.responseText);
var current_activity;
try {
current_activity = $.parseJSON(xhr.responseText);
} catch (e) {
console.log(status + ': ' + e);
current_activity = null;
}
if (!(current_activity)) {
$('#currentActivity').html('<div id="dashboard-no-activity" class="text-muted">There was an error communicating with your Plex Server.</div>');
return