log all failed ajax API requests

This commit is contained in:
MinRK 2014-04-23 13:17:50 -07:00
parent 748b2c64d5
commit 82964a09c2
7 changed files with 42 additions and 17 deletions

View File

@ -487,6 +487,18 @@ IPython.utils = (function (IPython) {
return false;
}
}
var log_ajax_error = function (jqXHR, status, error) {
// log ajax failures with informative messages
var msg = "API request failed (" + jqXHR.status + "): ";
console.log(jqXHR);
if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
msg += jqXHR.responseJSON.message;
} else {
msg += jqXHR.statusText;
}
console.log(msg);
};
return {
regex_split : regex_split,
@ -506,7 +518,8 @@ IPython.utils = (function (IPython) {
browser : browser,
platform: platform,
is_or_has : is_or_has,
is_focused : is_focused
is_focused : is_focused,
log_ajax_error : log_ajax_error,
};
}(IPython));

View File

@ -1885,7 +1885,8 @@ var IPython = (function (IPython) {
),
'_blank'
);
}
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
base_url,
@ -1913,7 +1914,8 @@ var IPython = (function (IPython) {
data.path,
data.name
), '_blank');
}
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
base_url,
@ -1956,6 +1958,7 @@ var IPython = (function (IPython) {
cache : false,
type : "DELETE",
dataType: "json",
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
this.base_url,
@ -2374,7 +2377,7 @@ var IPython = (function (IPython) {
$.ajax(url, {
type: 'DELETE',
success: $.proxy(this.delete_checkpoint_success, this),
error: $.proxy(this.delete_notebook_error,this)
error: $.proxy(this.delete_notebook_error, this)
});
};

View File

@ -397,7 +397,8 @@ var IPython = (function (IPython) {
this.running = false;
var settings = {
cache : false,
type : "DELETE"
type : "DELETE",
error : utils.log_ajax_error,
};
$.ajax(utils.url_join_encode(this.kernel_url), settings);
}

View File

@ -43,6 +43,7 @@ var IPython = (function (IPython) {
callback(data, status, xhr);
}
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(this.base_url, 'api/sessions');
$.ajax(url, settings);
@ -63,6 +64,7 @@ var IPython = (function (IPython) {
type : "PATCH",
data: JSON.stringify(model),
dataType : "json",
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
$.ajax(url, settings);
@ -74,6 +76,7 @@ var IPython = (function (IPython) {
cache : false,
type : "DELETE",
dataType : "json",
error : utils.log_ajax_error,
};
this.kernel.running = false;
var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);

View File

@ -49,7 +49,8 @@ var IPython = (function (IPython) {
cache : false,
type : "GET",
dataType : "json",
success : $.proxy(this.load_list_success, this)
success : $.proxy(this.load_list_success, this),
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(this.base_url, 'clusters');
$.ajax(url, settings);
@ -129,8 +130,9 @@ var IPython = (function (IPython) {
success : function (data, status, xhr) {
that.update_state(data);
},
error : function (data, status, xhr) {
error : function (xhr, status, error) {
status_col.text("error starting cluster");
utils.log_ajax_error(xhr, status, error);
}
};
status_col.text('starting');
@ -170,8 +172,8 @@ var IPython = (function (IPython) {
success : function (data, status, xhr) {
that.update_state(data);
},
error : function (data, status, xhr) {
console.log('error',data);
error : function (xhr, status, error) {
utils.log_ajax_error(xhr, status, error),
status_col.text("error stopping cluster");
}
};

View File

@ -131,7 +131,8 @@ var IPython = (function (IPython) {
type : "GET",
dataType : "json",
success : $.proxy(this.list_loaded, this),
error : $.proxy( function(){
error : $.proxy( function(xhr, status, error){
utils.log_ajax_error(xhr, status, error);
that.list_loaded([], null, null, {msg:"Error connecting to server."});
},this)
};
@ -273,7 +274,8 @@ var IPython = (function (IPython) {
dataType : "json",
success : function () {
that.load_sessions();
}
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
that.base_url,
@ -313,7 +315,8 @@ var IPython = (function (IPython) {
dataType : "json",
success : function (data, status, xhr) {
parent_item.remove();
}
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
notebooklist.base_url,
@ -359,9 +362,7 @@ var IPython = (function (IPython) {
that.add_link(path, nbname, item);
that.add_delete_button(item);
},
error : function (data, status, xhr) {
console.log(data, status);
}
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
@ -405,7 +406,8 @@ var IPython = (function (IPython) {
notebook_name),
'_blank'
);
}
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
base_url,

View File

@ -26,7 +26,8 @@ var IPython = (function (IPython) {
cache : false,
type : "GET",
dataType : "json",
success : $.proxy(that.sessions_loaded, this)
success : $.proxy(that.sessions_loaded, this),
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(this.base_url, 'api/sessions');
$.ajax(url, settings);