0
0
Fork 0

Fix 404 and 410 API errors being silently discarded in WebUI (#13279)

* Fix 404 and 410 API errors being silently discarded in WebUI

Fixes #13278

* Return more appropriate error when user replies to a deleted toot

* Please CodeClimate

* Fix 404/410 errors on fetching account timelines & identity proofs

* Refactor error handling

* Move error message string to statuses.errors
This commit is contained in:
ThibG 2020-03-28 17:59:45 +01:00 committed by GitHub
parent 7ddbbdea6d
commit 0d117c106a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 4 deletions

View file

@ -396,6 +396,7 @@ export function fetchFollowersFail(id, error) {
type: FOLLOWERS_FETCH_FAIL,
id,
error,
skipNotFound: true,
};
};
@ -482,6 +483,7 @@ export function fetchFollowingFail(id, error) {
type: FOLLOWING_FETCH_FAIL,
id,
error,
skipNotFound: true,
};
};
@ -571,6 +573,7 @@ export function fetchRelationshipsFail(error) {
type: RELATIONSHIPS_FETCH_FAIL,
error,
skipLoading: true,
skipNotFound: true,
};
};

View file

@ -34,11 +34,11 @@ export function showAlert(title = messages.unexpectedTitle, message = messages.u
};
};
export function showAlertForError(error) {
export function showAlertForError(error, skipNotFound = false) {
if (error.response) {
const { data, status, statusText, headers } = error.response;
if (status === 404 || status === 410) {
if (skipNotFound && (status === 404 || status === 410)) {
// Skip these errors as they are reflected in the UI
return { type: ALERT_NOOP };
}

View file

@ -27,4 +27,5 @@ export const fetchAccountIdentityProofsFail = (accountId, err) => ({
type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
accountId,
err,
skipNotFound: true,
});

View file

@ -149,6 +149,7 @@ export function expandTimelineFail(timeline, error, isLoadingMore) {
timeline,
error,
skipLoading: !isLoadingMore,
skipNotFound: timeline.startsWith('account:'),
};
};

View file

@ -8,7 +8,7 @@ export default function errorsMiddleware() {
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
if (action.type.match(isFail)) {
dispatch(showAlertForError(action.error));
dispatch(showAlertForError(action.error, action.skipNotFound));
}
}