1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Server not reachable notification displayed if server is down

This commit is contained in:
Laura Fuentes Grau 2020-10-23 12:52:35 +02:00
parent c5724e4195
commit de259acf45

View file

@ -36,9 +36,9 @@ const REQUEST_TIMEOUT_NOTIFICATION = {
// Can be used for the rest of requests
function isNetworkError(err) {
let result = false;
// If not status nor response fields, it is a network error. TODO: Handle timeouts
if (err.status == null || err.response == null) {
if (err.status == null || err.status == 500 || err.response == null) {
result = true;
let notification = err.timeout? REQUEST_TIMEOUT_NOTIFICATION : SERVER_NOT_REACHABLE_NOTIFICATION;
@ -58,6 +58,7 @@ class RestAPI {
req.end(function (error, res) {
if (res == null || res.status !== 200) {
error.handled = isNetworkError(error);
reject(error);
} else {
resolve(JSON.parse(res.text));
@ -97,6 +98,7 @@ class RestAPI {
req.end(function (error, res) {
if (res == null || res.status !== 200) {
error.handled = isNetworkError(error);
reject(error);
} else {
resolve(JSON.parse(res.text));
@ -115,6 +117,7 @@ class RestAPI {
req.end(function (error, res) {
if (res == null || res.status !== 200) {
error.handled = isNetworkError(error);
reject(error);
} else {
resolve(JSON.parse(res.text));
@ -133,6 +136,7 @@ class RestAPI {
req.end(function (error, res) {
if (res == null || res.status !== 200) {
error.handled = isNetworkError(error);
reject(error);
} else {
resolve(JSON.parse(res.text));
@ -152,6 +156,7 @@ class RestAPI {
req.end(function (error, res) {
if (error !== null || res.status !== 200) {
error.handled = isNetworkError(error);
reject(error);
} else {
// file data is contained in res.body (because of blob response type)