mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed error handling
This commit is contained in:
parent
b95d53791c
commit
0873e77ff4
5 changed files with 20 additions and 19 deletions
|
@ -234,7 +234,7 @@ function* requestRestoreCode({ field }: ReturnType<typeof authRequestRestoreCode
|
|||
|
||||
yield put(authSetRestore({ is_loading: false, is_succesfull: true }));
|
||||
} catch (error) {
|
||||
return yield put(authSetRestore({ is_loading: false, error }));
|
||||
return yield put(authSetRestore({ is_loading: false, error: error.message }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,9 @@ function* showRestoreModal({ code }: ReturnType<typeof authShowRestoreModal>) {
|
|||
yield put(authSetRestore({ user: data.user, code, is_loading: false }));
|
||||
yield put(modalShowDialog(DIALOGS.RESTORE_PASSWORD));
|
||||
} catch (error) {
|
||||
yield put(authSetRestore({ is_loading: false, error: error || ERRORS.CODE_IS_INVALID }));
|
||||
yield put(
|
||||
authSetRestore({ is_loading: false, error: error.message || ERRORS.CODE_IS_INVALID })
|
||||
);
|
||||
yield put(modalShowDialog(DIALOGS.RESTORE_PASSWORD));
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +278,9 @@ function* restorePassword({ password }: ReturnType<typeof authRestorePassword>)
|
|||
|
||||
yield call(refreshUser);
|
||||
} catch (error) {
|
||||
return yield put(authSetRestore({ is_loading: false, error: error || ERRORS.CODE_IS_INVALID }));
|
||||
return yield put(
|
||||
authSetRestore({ is_loading: false, error: error.message || ERRORS.CODE_IS_INVALID })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +290,7 @@ function* getSocials() {
|
|||
const data: Unwrap<typeof apiGetSocials> = yield call(apiGetSocials);
|
||||
yield put(authSetSocials({ accounts: data.accounts }));
|
||||
} catch (error) {
|
||||
yield put(authSetSocials({ error }));
|
||||
yield put(authSetSocials({ error: error.message }));
|
||||
} finally {
|
||||
yield put(authSetSocials({ is_loading: false }));
|
||||
}
|
||||
|
@ -303,7 +307,7 @@ function* dropSocial({ provider, id }: ReturnType<typeof authDropSocial>) {
|
|||
|
||||
yield call(getSocials);
|
||||
} catch (error) {
|
||||
yield put(authSetSocials({ error }));
|
||||
yield put(authSetSocials({ error: error.message }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,7 +359,7 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
|
|||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(userSetLoginError(error));
|
||||
yield put(userSetLoginError(error.message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,7 +404,7 @@ function* authRegisterSocial({ username, password }: ReturnType<typeof authSendR
|
|||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(authSetRegisterSocial({ error }));
|
||||
yield put(authSetRegisterSocial({ error: error.message }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ function* getMessages({ username }: ReturnType<typeof messagesGetMessages>) {
|
|||
}
|
||||
} catch (error) {
|
||||
messagesSet({
|
||||
error: error || ERRORS.EMPTY_RESPONSE,
|
||||
error: error.message || ERRORS.EMPTY_RESPONSE,
|
||||
});
|
||||
} finally {
|
||||
yield put(
|
||||
|
@ -110,7 +110,7 @@ function* sendMessage({ message, onSuccess }: ReturnType<typeof messagesSendMess
|
|||
onSuccess();
|
||||
} catch (error) {
|
||||
messagesSet({
|
||||
error: error || ERRORS.EMPTY_RESPONSE,
|
||||
error: error.message || ERRORS.EMPTY_RESPONSE,
|
||||
});
|
||||
} finally {
|
||||
yield put(
|
||||
|
@ -155,7 +155,7 @@ function* deleteMessage({ id, is_locked }: ReturnType<typeof messagesDeleteMessa
|
|||
);
|
||||
} catch (error) {
|
||||
messagesSet({
|
||||
error: error || ERRORS.EMPTY_RESPONSE,
|
||||
error: error.message || ERRORS.EMPTY_RESPONSE,
|
||||
});
|
||||
} finally {
|
||||
yield put(
|
||||
|
@ -193,7 +193,7 @@ function* refreshMessages({}: ReturnType<typeof messagesRefreshMessages>) {
|
|||
yield put(messagesSet({ messages: newMessages }));
|
||||
} catch (error) {
|
||||
messagesSet({
|
||||
error: error || ERRORS.EMPTY_RESPONSE,
|
||||
error: error.message || ERRORS.EMPTY_RESPONSE,
|
||||
});
|
||||
} finally {
|
||||
yield put(
|
||||
|
|
|
@ -99,7 +99,7 @@ function* onNodeSave({ node }: ReturnType<typeof nodeSave>) {
|
|||
|
||||
return yield put(modalSetShown(false));
|
||||
} catch (error) {
|
||||
yield put(nodeSetSaveErrors({ error: error || ERRORS.CANT_SAVE_NODE }));
|
||||
yield put(nodeSetSaveErrors({ error: error.message || ERRORS.CANT_SAVE_NODE }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ function* onPostComment({ nodeId, comment, callback }: ReturnType<typeof nodePos
|
|||
callback();
|
||||
}
|
||||
} catch (error) {
|
||||
return callback(error);
|
||||
return callback(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,15 +131,12 @@ export function configureStore(): {
|
|||
});
|
||||
|
||||
// Logout on 401
|
||||
api.interceptors.response.use(undefined, (error: AxiosError<{ message: string }>) => {
|
||||
api.interceptors.response.use(undefined, (error: AxiosError<{ error: string }>) => {
|
||||
if (error.response?.status === 401) {
|
||||
store.dispatch(authLogout());
|
||||
}
|
||||
|
||||
console.log('Вот что случилось на сервере:', error);
|
||||
throw new Error(
|
||||
error?.response?.data?.message || error?.message || error?.response?.statusText
|
||||
);
|
||||
throw new Error(error?.response?.data?.error || error?.message || error?.response?.statusText);
|
||||
});
|
||||
|
||||
return { store, persistor };
|
||||
|
|
|
@ -133,7 +133,7 @@ function* uploadFile({ file, temp_id, type, target, onSuccess, onFail }: IFileWi
|
|||
return yield put(
|
||||
uploadSetStatus(temp_id, {
|
||||
is_uploading: false,
|
||||
error,
|
||||
error: error.message,
|
||||
type,
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue