Skip to content

Commit

Permalink
Catch errors in github popup
Browse files Browse the repository at this point in the history
refs #1439.
  • Loading branch information
rwstauner committed Jan 10, 2015
1 parent a4c8101 commit be33f00
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion root/static/js/github.js
Expand Up @@ -124,6 +124,20 @@ function Github() {
type: 'GET',
url: this.url,
success: function(res, status) {

var error;
try {
// If there was an error data will likely
// contain only "documentation_url" and "message".
if( res.meta && res.meta.status >= 400 ){
error = res.data && res.data.message || 'An error occurred';
}
} catch(ignore){ }
if( error ){
this.set('content.text', '<i>' + error + '</i>');
return;
}

var qtip = this;
var data = self.prepareData(res.data, function(data) {
var html = self.render(data);
Expand Down Expand Up @@ -192,7 +206,13 @@ function Github() {
},

render: function(data) {
return this.config[this.type].render(this, data);
try {
return this.config[this.type].render(this, data);
}
catch(x) {
// Don't let the spinner spin forever.
return '<i>Error</i>';
}
}
}
};
Expand Down

0 comments on commit be33f00

Please sign in to comment.