Skip to content

Commit 691baa2

Browse files
committed
Do not auto-logout on network errors
1 parent 54647d7 commit 691baa2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/commons/sagas/RequestsSaga.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,14 +1301,26 @@ export const request = async (
13011301
return resp;
13021302
}
13031303

1304-
if (!resp || !resp.ok) {
1305-
throw new Error('API call failed or got non-OK response');
1304+
if (!resp.ok) {
1305+
showWarningMessage(
1306+
opts.errorMessage
1307+
? opts.errorMessage
1308+
: `Error while communicating with backend: ${resp.status} ${resp.statusText}${
1309+
resp.status === 401 || resp.status === 403
1310+
? '; try logging in again, after manually saving any work.'
1311+
: ''
1312+
}`
1313+
);
1314+
return null;
13061315
}
13071316

13081317
return resp;
13091318
} catch (e) {
1310-
store.dispatch(actions.logOut());
1311-
showWarningMessage(opts.errorMessage ? opts.errorMessage : 'Please login again.');
1319+
showWarningMessage(
1320+
opts.errorMessage
1321+
? opts.errorMessage
1322+
: 'Error while communicating with backend; check your network?'
1323+
);
13121324

13131325
return null;
13141326
}

0 commit comments

Comments
 (0)