mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
log all failed ajax API requests
This commit is contained in:
parent
748b2c64d5
commit
82964a09c2
@ -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));
|
||||
|
@ -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)
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user