Unverified Commit 341e40d0 authored by Dan Jones's avatar Dan Jones
Browse files

fix: correct reference to error status code

+ add catch and retry in poll method
parent b66f89a7
......@@ -82,10 +82,11 @@ class Adapter {
/**
* Call the GET /receive endpoint and process the messages with decode
*
* Returns the response
* Returns the response
* @param {boolean} is_retry
* @returns {object}
*/
poll() {
poll(is_retry=false) {
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
......@@ -105,7 +106,18 @@ class Adapter {
return response;
})
.catch((error) => {
return Promise.reject(error);
let retry = false;
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
} break;
case 503: {
retry = true;
}
}
if (retry && !is_retry) return this.poll(true);
else return Promise.reject(error);
});
}
......@@ -138,7 +150,7 @@ class Adapter {
})
.catch((error) => {
let retry = false;
switch(error.response.status_code) {
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
......@@ -183,7 +195,7 @@ class Adapter {
})
.catch((error) => {
let retry = false;
switch(error.response.status_code) {
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
......
......@@ -84,10 +84,11 @@ class Adapter {
/**
* Call the GET /receive endpoint and process the messages with decode
*
* Returns the response
* Returns the response
* @param {boolean} is_retry
* @returns {object}
*/
poll() {
poll(is_retry=false) {
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
......@@ -107,7 +108,18 @@ class Adapter {
return response;
})
.catch((error) => {
return Promise.reject(error);
let retry = false;
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
} break;
case 503: {
retry = true;
}
}
if (retry && !is_retry) return this.poll(true);
else return Promise.reject(error);
});
}
......@@ -140,7 +152,7 @@ class Adapter {
})
.catch((error) => {
let retry = false;
switch(error.response.status_code) {
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
......@@ -185,7 +197,7 @@ class Adapter {
})
.catch((error) => {
let retry = false;
switch(error.response.status_code) {
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
......
......@@ -82,10 +82,11 @@ export class Adapter {
/**
* Call the GET /receive endpoint and process the messages with decode
*
* Returns the response
* Returns the response
* @param {boolean} is_retry
* @returns {object}
*/
poll() {
poll(is_retry=false) {
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
......@@ -105,7 +106,18 @@ export class Adapter {
return response;
})
.catch((error) => {
return Promise.reject(error);
let retry = false;
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
} break;
case 503: {
retry = true;
}
}
if (retry && !is_retry) return this.poll(true);
else return Promise.reject(error);
});
}
......@@ -138,7 +150,7 @@ export class Adapter {
})
.catch((error) => {
let retry = false;
switch(error.response.status_code) {
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
......@@ -183,7 +195,7 @@ export class Adapter {
})
.catch((error) => {
let retry = false;
switch(error.response.status_code) {
switch(error.response.status) {
case 403: {
this.credentials = null;
retry = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment