Skip to content

Commit

Permalink
[hotfix] handling json errors in explore view
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Oct 13, 2016
1 parent 89cb726 commit 5bea398
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions caravel/assets/javascripts/modules/caravel.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,25 @@ const px = function () {
return msg;
},
error(msg, xhr) {
let errorMsg = msg;
token.find('img.loading').hide();
let err = msg ? '<div class="alert alert-danger">' + msg + '</div>' : '';
let errHtml = '';
try {
const o = JSON.parse(msg);
if (o.error) {
errorMsg = o.error;
}
} catch (e) {
// pass
}
errHtml = `<div class="alert alert-danger">${errorMsg}</div>`;
if (xhr) {
const extendedMsg = this.getErrorMsg(xhr);
if (extendedMsg) {
err += '<div class="alert alert-danger">' + extendedMsg + '</div>';
errHtml += `<div class="alert alert-danger">${extendedMsg}</div>`;
}
}
container.html(err);
container.html(errHtml);
container.show();
$('span.query').removeClass('disabled');
$('#timer').addClass('btn-danger');
Expand Down
1 change: 1 addition & 0 deletions caravel/assets/javascripts/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const controllerInterface = {
getFilters: () => false,
clearFilter: () => {},
removeFilter: () => {},
filters: {},
};

module.exports = {
Expand Down

0 comments on commit 5bea398

Please sign in to comment.