Funnel exceptions from ajax handlers through blueslip

(imported from commit 5ad08482989d25a0fd0ee02251b74a23f950a0b9)
This commit is contained in:
Zev Benjamin 2013-03-13 18:27:39 -04:00
parent 7510f87eac
commit dfe69eef0d
1 changed files with 11 additions and 2 deletions

View File

@ -75,8 +75,9 @@ function BlueslipError() {
BlueslipError.prototype = Error.prototype;
// Catch all exceptions from jQuery event handlers and
// $(document).ready functions and funnel them through blueslip.
// Catch all exceptions from jQuery event handlers, $(document).ready
// functions, and ajax success/failure continuations and funnel them
// through blueslip.
(function() {
function wrap_callback(func) {
var new_func = function blueslip_wrapper() {
@ -100,6 +101,14 @@ BlueslipError.prototype = Error.prototype;
return new_func;
}
$.ajaxPrefilter(function (options) {
$.each(['success', 'error', 'complete'], function (idx, cb_name) {
if (options[cb_name] !== undefined) {
options[cb_name] = wrap_callback(options[cb_name]);
}
});
});
if (document.addEventListener) {
var orig_on = $.fn.on;
var orig_ready = $.fn.ready;