##// END OF EJS Templates
Backport PR #5715: log all failed ajax API requests...
Thomas Kluyver -
Show More
@@ -487,6 +487,18 b' IPython.utils = (function (IPython) {'
487 return false;
487 return false;
488 }
488 }
489 }
489 }
490
491 var log_ajax_error = function (jqXHR, status, error) {
492 // log ajax failures with informative messages
493 var msg = "API request failed (" + jqXHR.status + "): ";
494 console.log(jqXHR);
495 if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
496 msg += jqXHR.responseJSON.message;
497 } else {
498 msg += jqXHR.statusText;
499 }
500 console.log(msg);
501 };
490
502
491 return {
503 return {
492 regex_split : regex_split,
504 regex_split : regex_split,
@@ -506,7 +518,8 b' IPython.utils = (function (IPython) {'
506 browser : browser,
518 browser : browser,
507 platform: platform,
519 platform: platform,
508 is_or_has : is_or_has,
520 is_or_has : is_or_has,
509 is_focused : is_focused
521 is_focused : is_focused,
522 log_ajax_error : log_ajax_error,
510 };
523 };
511
524
512 }(IPython));
525 }(IPython));
@@ -1885,7 +1885,8 b' var IPython = (function (IPython) {'
1885 ),
1885 ),
1886 '_blank'
1886 '_blank'
1887 );
1887 );
1888 }
1888 },
1889 error : utils.log_ajax_error,
1889 };
1890 };
1890 var url = utils.url_join_encode(
1891 var url = utils.url_join_encode(
1891 base_url,
1892 base_url,
@@ -1913,7 +1914,8 b' var IPython = (function (IPython) {'
1913 data.path,
1914 data.path,
1914 data.name
1915 data.name
1915 ), '_blank');
1916 ), '_blank');
1916 }
1917 },
1918 error : utils.log_ajax_error,
1917 };
1919 };
1918 var url = utils.url_join_encode(
1920 var url = utils.url_join_encode(
1919 base_url,
1921 base_url,
@@ -1956,6 +1958,7 b' var IPython = (function (IPython) {'
1956 cache : false,
1958 cache : false,
1957 type : "DELETE",
1959 type : "DELETE",
1958 dataType: "json",
1960 dataType: "json",
1961 error : utils.log_ajax_error,
1959 };
1962 };
1960 var url = utils.url_join_encode(
1963 var url = utils.url_join_encode(
1961 this.base_url,
1964 this.base_url,
@@ -2374,7 +2377,7 b' var IPython = (function (IPython) {'
2374 $.ajax(url, {
2377 $.ajax(url, {
2375 type: 'DELETE',
2378 type: 'DELETE',
2376 success: $.proxy(this.delete_checkpoint_success, this),
2379 success: $.proxy(this.delete_checkpoint_success, this),
2377 error: $.proxy(this.delete_notebook_error,this)
2380 error: $.proxy(this.delete_checkpoint_error, this)
2378 });
2381 });
2379 };
2382 };
2380
2383
@@ -395,7 +395,8 b' var IPython = (function (IPython) {'
395 this.running = false;
395 this.running = false;
396 var settings = {
396 var settings = {
397 cache : false,
397 cache : false,
398 type : "DELETE"
398 type : "DELETE",
399 error : utils.log_ajax_error,
399 };
400 };
400 $.ajax(utils.url_join_encode(this.kernel_url), settings);
401 $.ajax(utils.url_join_encode(this.kernel_url), settings);
401 }
402 }
@@ -43,6 +43,7 b' var IPython = (function (IPython) {'
43 callback(data, status, xhr);
43 callback(data, status, xhr);
44 }
44 }
45 },
45 },
46 error : utils.log_ajax_error,
46 };
47 };
47 var url = utils.url_join_encode(this.base_url, 'api/sessions');
48 var url = utils.url_join_encode(this.base_url, 'api/sessions');
48 $.ajax(url, settings);
49 $.ajax(url, settings);
@@ -63,6 +64,7 b' var IPython = (function (IPython) {'
63 type : "PATCH",
64 type : "PATCH",
64 data: JSON.stringify(model),
65 data: JSON.stringify(model),
65 dataType : "json",
66 dataType : "json",
67 error : utils.log_ajax_error,
66 };
68 };
67 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
69 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
68 $.ajax(url, settings);
70 $.ajax(url, settings);
@@ -74,6 +76,7 b' var IPython = (function (IPython) {'
74 cache : false,
76 cache : false,
75 type : "DELETE",
77 type : "DELETE",
76 dataType : "json",
78 dataType : "json",
79 error : utils.log_ajax_error,
77 };
80 };
78 this.kernel.running = false;
81 this.kernel.running = false;
79 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
82 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
@@ -49,7 +49,8 b' var IPython = (function (IPython) {'
49 cache : false,
49 cache : false,
50 type : "GET",
50 type : "GET",
51 dataType : "json",
51 dataType : "json",
52 success : $.proxy(this.load_list_success, this)
52 success : $.proxy(this.load_list_success, this),
53 error : utils.log_ajax_error,
53 };
54 };
54 var url = utils.url_join_encode(this.base_url, 'clusters');
55 var url = utils.url_join_encode(this.base_url, 'clusters');
55 $.ajax(url, settings);
56 $.ajax(url, settings);
@@ -129,8 +130,9 b' var IPython = (function (IPython) {'
129 success : function (data, status, xhr) {
130 success : function (data, status, xhr) {
130 that.update_state(data);
131 that.update_state(data);
131 },
132 },
132 error : function (data, status, xhr) {
133 error : function (xhr, status, error) {
133 status_col.text("error starting cluster");
134 status_col.text("error starting cluster");
135 utils.log_ajax_error(xhr, status, error);
134 }
136 }
135 };
137 };
136 status_col.text('starting');
138 status_col.text('starting');
@@ -170,8 +172,8 b' var IPython = (function (IPython) {'
170 success : function (data, status, xhr) {
172 success : function (data, status, xhr) {
171 that.update_state(data);
173 that.update_state(data);
172 },
174 },
173 error : function (data, status, xhr) {
175 error : function (xhr, status, error) {
174 console.log('error',data);
176 utils.log_ajax_error(xhr, status, error),
175 status_col.text("error stopping cluster");
177 status_col.text("error stopping cluster");
176 }
178 }
177 };
179 };
@@ -131,7 +131,8 b' var IPython = (function (IPython) {'
131 type : "GET",
131 type : "GET",
132 dataType : "json",
132 dataType : "json",
133 success : $.proxy(this.list_loaded, this),
133 success : $.proxy(this.list_loaded, this),
134 error : $.proxy( function(){
134 error : $.proxy( function(xhr, status, error){
135 utils.log_ajax_error(xhr, status, error);
135 that.list_loaded([], null, null, {msg:"Error connecting to server."});
136 that.list_loaded([], null, null, {msg:"Error connecting to server."});
136 },this)
137 },this)
137 };
138 };
@@ -273,7 +274,8 b' var IPython = (function (IPython) {'
273 dataType : "json",
274 dataType : "json",
274 success : function () {
275 success : function () {
275 that.load_sessions();
276 that.load_sessions();
276 }
277 },
278 error : utils.log_ajax_error,
277 };
279 };
278 var url = utils.url_join_encode(
280 var url = utils.url_join_encode(
279 that.base_url,
281 that.base_url,
@@ -313,7 +315,8 b' var IPython = (function (IPython) {'
313 dataType : "json",
315 dataType : "json",
314 success : function (data, status, xhr) {
316 success : function (data, status, xhr) {
315 parent_item.remove();
317 parent_item.remove();
316 }
318 },
319 error : utils.log_ajax_error,
317 };
320 };
318 var url = utils.url_join_encode(
321 var url = utils.url_join_encode(
319 notebooklist.base_url,
322 notebooklist.base_url,
@@ -359,9 +362,7 b' var IPython = (function (IPython) {'
359 that.add_link(path, nbname, item);
362 that.add_link(path, nbname, item);
360 that.add_delete_button(item);
363 that.add_delete_button(item);
361 },
364 },
362 error : function (data, status, xhr) {
365 error : utils.log_ajax_error,
363 console.log(data, status);
364 }
365 };
366 };
366
367
367 var url = utils.url_join_encode(
368 var url = utils.url_join_encode(
@@ -405,7 +406,8 b' var IPython = (function (IPython) {'
405 notebook_name),
406 notebook_name),
406 '_blank'
407 '_blank'
407 );
408 );
408 }
409 },
410 error : $.proxy(this.new_notebook_failed, this),
409 };
411 };
410 var url = utils.url_join_encode(
412 var url = utils.url_join_encode(
411 base_url,
413 base_url,
@@ -414,7 +416,24 b' var IPython = (function (IPython) {'
414 );
416 );
415 $.ajax(url, settings);
417 $.ajax(url, settings);
416 };
418 };
417
419
420
421 NotebookList.prototype.new_notebook_failed = function (xhr, status, error) {
422 utils.log_ajax_error(xhr, status, error);
423 var msg;
424 if (xhr.responseJSON && xhr.responseJSON.message) {
425 msg = xhr.responseJSON.message;
426 } else {
427 msg = xhr.statusText;
428 }
429 IPython.dialog.modal({
430 title : 'Creating Notebook Failed',
431 body : "The error was: " + msg,
432 buttons : {'OK' : {'class' : 'btn-primary'}}
433 });
434 }
435
436
418 IPython.NotebookList = NotebookList;
437 IPython.NotebookList = NotebookList;
419
438
420 return IPython;
439 return IPython;
@@ -26,7 +26,8 b' var IPython = (function (IPython) {'
26 cache : false,
26 cache : false,
27 type : "GET",
27 type : "GET",
28 dataType : "json",
28 dataType : "json",
29 success : $.proxy(that.sessions_loaded, this)
29 success : $.proxy(that.sessions_loaded, this),
30 error : utils.log_ajax_error,
30 };
31 };
31 var url = utils.url_join_encode(this.base_url, 'api/sessions');
32 var url = utils.url_join_encode(this.base_url, 'api/sessions');
32 $.ajax(url, settings);
33 $.ajax(url, settings);
General Comments 0
You need to be logged in to leave comments. Login now