Improve stack traces on HTTPErrors
Save stack even earlier, outside the promise. // FREEBIE
This commit is contained in:
parent
c062fe3060
commit
81ebc5ffd7
2 changed files with 6 additions and 6 deletions
|
@ -38733,7 +38733,6 @@ var TextSecureServer = (function() {
|
||||||
function promise_ajax(url, options) {
|
function promise_ajax(url, options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
console.log(options.type, url);
|
console.log(options.type, url);
|
||||||
var error = new Error(); // just in case, save stack here.
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(options.type, url, true /*async*/);
|
xhr.open(options.type, url, true /*async*/);
|
||||||
|
|
||||||
|
@ -38761,18 +38760,19 @@ var TextSecureServer = (function() {
|
||||||
resolve(result, xhr.status);
|
resolve(result, xhr.status);
|
||||||
} else {
|
} else {
|
||||||
console.log(options.type, url, xhr.status, 'Error');
|
console.log(options.type, url, xhr.status, 'Error');
|
||||||
reject(HTTPError(xhr.status, result, error.stack));
|
reject(HTTPError(xhr.status, result, options.stack));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
console.log(options.type, url, xhr.status, 'Error');
|
console.log(options.type, url, xhr.status, 'Error');
|
||||||
reject(HTTPError(xhr.status, null, error.stack));
|
reject(HTTPError(xhr.status, null, options.stack));
|
||||||
};
|
};
|
||||||
xhr.send( options.data || null );
|
xhr.send( options.data || null );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax(url, options) {
|
function ajax(url, options) {
|
||||||
|
options.stack = new Error().stack; // just in case, save stack here.
|
||||||
var count = 3;
|
var count = 3;
|
||||||
|
|
||||||
function retry(e) {
|
function retry(e) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ var TextSecureServer = (function() {
|
||||||
function promise_ajax(url, options) {
|
function promise_ajax(url, options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
console.log(options.type, url);
|
console.log(options.type, url);
|
||||||
var error = new Error(); // just in case, save stack here.
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(options.type, url, true /*async*/);
|
xhr.open(options.type, url, true /*async*/);
|
||||||
|
|
||||||
|
@ -37,18 +36,19 @@ var TextSecureServer = (function() {
|
||||||
resolve(result, xhr.status);
|
resolve(result, xhr.status);
|
||||||
} else {
|
} else {
|
||||||
console.log(options.type, url, xhr.status, 'Error');
|
console.log(options.type, url, xhr.status, 'Error');
|
||||||
reject(HTTPError(xhr.status, result, error.stack));
|
reject(HTTPError(xhr.status, result, options.stack));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
console.log(options.type, url, xhr.status, 'Error');
|
console.log(options.type, url, xhr.status, 'Error');
|
||||||
reject(HTTPError(xhr.status, null, error.stack));
|
reject(HTTPError(xhr.status, null, options.stack));
|
||||||
};
|
};
|
||||||
xhr.send( options.data || null );
|
xhr.send( options.data || null );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax(url, options) {
|
function ajax(url, options) {
|
||||||
|
options.stack = new Error().stack; // just in case, save stack here.
|
||||||
var count = 3;
|
var count = 3;
|
||||||
|
|
||||||
function retry(e) {
|
function retry(e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue