##// 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 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 503 return {
492 504 regex_split : regex_split,
@@ -506,7 +518,8 b' IPython.utils = (function (IPython) {'
506 518 browser : browser,
507 519 platform: platform,
508 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 525 }(IPython));
@@ -1885,7 +1885,8 b' var IPython = (function (IPython) {'
1885 1885 ),
1886 1886 '_blank'
1887 1887 );
1888 }
1888 },
1889 error : utils.log_ajax_error,
1889 1890 };
1890 1891 var url = utils.url_join_encode(
1891 1892 base_url,
@@ -1913,7 +1914,8 b' var IPython = (function (IPython) {'
1913 1914 data.path,
1914 1915 data.name
1915 1916 ), '_blank');
1916 }
1917 },
1918 error : utils.log_ajax_error,
1917 1919 };
1918 1920 var url = utils.url_join_encode(
1919 1921 base_url,
@@ -1956,6 +1958,7 b' var IPython = (function (IPython) {'
1956 1958 cache : false,
1957 1959 type : "DELETE",
1958 1960 dataType: "json",
1961 error : utils.log_ajax_error,
1959 1962 };
1960 1963 var url = utils.url_join_encode(
1961 1964 this.base_url,
@@ -2374,7 +2377,7 b' var IPython = (function (IPython) {'
2374 2377 $.ajax(url, {
2375 2378 type: 'DELETE',
2376 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 395 this.running = false;
396 396 var settings = {
397 397 cache : false,
398 type : "DELETE"
398 type : "DELETE",
399 error : utils.log_ajax_error,
399 400 };
400 401 $.ajax(utils.url_join_encode(this.kernel_url), settings);
401 402 }
@@ -43,6 +43,7 b' var IPython = (function (IPython) {'
43 43 callback(data, status, xhr);
44 44 }
45 45 },
46 error : utils.log_ajax_error,
46 47 };
47 48 var url = utils.url_join_encode(this.base_url, 'api/sessions');
48 49 $.ajax(url, settings);
@@ -63,6 +64,7 b' var IPython = (function (IPython) {'
63 64 type : "PATCH",
64 65 data: JSON.stringify(model),
65 66 dataType : "json",
67 error : utils.log_ajax_error,
66 68 };
67 69 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
68 70 $.ajax(url, settings);
@@ -74,6 +76,7 b' var IPython = (function (IPython) {'
74 76 cache : false,
75 77 type : "DELETE",
76 78 dataType : "json",
79 error : utils.log_ajax_error,
77 80 };
78 81 this.kernel.running = false;
79 82 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
@@ -49,7 +49,8 b' var IPython = (function (IPython) {'
49 49 cache : false,
50 50 type : "GET",
51 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 55 var url = utils.url_join_encode(this.base_url, 'clusters');
55 56 $.ajax(url, settings);
@@ -129,8 +130,9 b' var IPython = (function (IPython) {'
129 130 success : function (data, status, xhr) {
130 131 that.update_state(data);
131 132 },
132 error : function (data, status, xhr) {
133 error : function (xhr, status, error) {
133 134 status_col.text("error starting cluster");
135 utils.log_ajax_error(xhr, status, error);
134 136 }
135 137 };
136 138 status_col.text('starting');
@@ -170,8 +172,8 b' var IPython = (function (IPython) {'
170 172 success : function (data, status, xhr) {
171 173 that.update_state(data);
172 174 },
173 error : function (data, status, xhr) {
174 console.log('error',data);
175 error : function (xhr, status, error) {
176 utils.log_ajax_error(xhr, status, error),
175 177 status_col.text("error stopping cluster");
176 178 }
177 179 };
@@ -131,7 +131,8 b' var IPython = (function (IPython) {'
131 131 type : "GET",
132 132 dataType : "json",
133 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 136 that.list_loaded([], null, null, {msg:"Error connecting to server."});
136 137 },this)
137 138 };
@@ -273,7 +274,8 b' var IPython = (function (IPython) {'
273 274 dataType : "json",
274 275 success : function () {
275 276 that.load_sessions();
276 }
277 },
278 error : utils.log_ajax_error,
277 279 };
278 280 var url = utils.url_join_encode(
279 281 that.base_url,
@@ -313,7 +315,8 b' var IPython = (function (IPython) {'
313 315 dataType : "json",
314 316 success : function (data, status, xhr) {
315 317 parent_item.remove();
316 }
318 },
319 error : utils.log_ajax_error,
317 320 };
318 321 var url = utils.url_join_encode(
319 322 notebooklist.base_url,
@@ -359,9 +362,7 b' var IPython = (function (IPython) {'
359 362 that.add_link(path, nbname, item);
360 363 that.add_delete_button(item);
361 364 },
362 error : function (data, status, xhr) {
363 console.log(data, status);
364 }
365 error : utils.log_ajax_error,
365 366 };
366 367
367 368 var url = utils.url_join_encode(
@@ -405,7 +406,8 b' var IPython = (function (IPython) {'
405 406 notebook_name),
406 407 '_blank'
407 408 );
408 }
409 },
410 error : $.proxy(this.new_notebook_failed, this),
409 411 };
410 412 var url = utils.url_join_encode(
411 413 base_url,
@@ -414,7 +416,24 b' var IPython = (function (IPython) {'
414 416 );
415 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 437 IPython.NotebookList = NotebookList;
419 438
420 439 return IPython;
@@ -26,7 +26,8 b' var IPython = (function (IPython) {'
26 26 cache : false,
27 27 type : "GET",
28 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 32 var url = utils.url_join_encode(this.base_url, 'api/sessions');
32 33 $.ajax(url, settings);
General Comments 0
You need to be logged in to leave comments. Login now