1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

fix error throwing in requests

This commit is contained in:
Tim Daubenschütz 2015-07-17 16:23:25 +02:00
parent f215026f8b
commit 263a7b2676

View File

@ -19,9 +19,9 @@ class Requests {
unpackResponse(response) { unpackResponse(response) {
if (response.status >= 500) { if (response.status >= 500) {
console.logGlobal(new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url)); throw new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url);
} else if(response.status >= 400 && response.status < 500) { } else if(response.status >= 400) {
console.logGlobal(new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url)); throw new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url);
} }
return response.text(); return response.text();
} }
@ -39,9 +39,9 @@ class Requests {
handleError(err) { handleError(err) {
if (err instanceof TypeError) { if (err instanceof TypeError) {
console.logGlobal('Server did not respond to the request. (Not even displayed a 500)'); throw new Error('Server did not respond to the request. (Not even displayed a 500)');
} else { } else {
console.logGlobal(err); throw err;
} }
} }