Improve handling when bot is down

This commit is contained in:
Matthias 2020-06-23 19:57:15 +02:00
parent a0ca9f6793
commit c5eadc3d3d
2 changed files with 9 additions and 6 deletions

View File

@ -30,8 +30,7 @@ api.interceptors.response.use(
console.log('Dispatching refresh_token...');
userService.refreshToken();
// maybe redirect to /login if needed !
}
if (err.response && err.response.status === 500) {
} else if (err.response && err.response.status === 500) {
console.log('Bot seems to be offline...');
}
return new Promise((resolve, reject) => {

View File

@ -63,10 +63,14 @@ export default {
this.setAccessToken(result.data.access_token);
}
})
.catch((error) => {
console.error(error);
// in case of errors when using the refresh token - logout.
this.logout();
.catch((err) => {
console.error(err);
if (err.response && err.response.status === 401) {
// in case of errors when using the refresh token - logout.
this.logout();
} else if (err.response && (err.response.status === 500 || err.response.status === 404)) {
console.log('Bot seems to be offline... - retrying later');
}
});
},