本文整理匯總了TypeScript中@asuna-admin/helpers.toErrorMessage函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript toErrorMessage函數的具體用法?TypeScript toErrorMessage怎麽用?TypeScript toErrorMessage使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了toErrorMessage函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: loginSaga
function* loginSaga({ payload: { username, password }, callback }) {
const auth: AuthState = yield select((state: RootState) => state.auth);
try {
const response = yield call(authProxy.login, username, password);
logger.log('[loginSaga]', 'response is', response);
// 切換用戶時更新操作區域,如果未來需要保存當前頁麵配置的話,應該將切換操作提出為單獨的 Saga
if (auth.username !== username) {
yield put(panesActions.closeAll());
}
if (callback) callback({ response });
const token = yield call(authProxy.extractToken, response.data);
yield put(authActions.loginSuccess(username, token));
message.info(`'${username}' login success`);
yield put(routerActions.toIndex());
} catch (error) {
logger.error('[loginSaga]', { error });
try {
if (callback != null) callback({ error });
} catch (e) {
logger.warn('[upsert] callback error', e, { e });
}
if (error.response) {
yield put(authActions.loginFailed(error.response));
message.error(toErrorMessage(error));
}
}
}
示例2: loadModels
function* loadModels({ payload: { name, models } }: LoadModelsParams) {
const { token } = yield select((state: RootState) => state.auth);
if (token) {
try {
const {
[name]: { extras },
} = models;
logger.debug('[loadModels]', 'loading content', { name, extras });
message.loading(`loading content '${name}'...`);
const response = yield call(AppContext.adapters.models.loadModels, name, extras);
message.success(`load content '${name}' success`);
logger.log('[loadModels]', 'loaded content', { name, response });
yield put(
contentActions.loadModelsSuccess({
[name]: { data: response.data, loading: false },
}),
);
} catch (e) {
logger.warn('[loadModels]', { e });
message.error(toErrorMessage(e));
}
}
}
示例3: select
// }
// --------------------------------------------------------------
const securitySagaFunctions = {
*loadAllRoles() {
const { token } = yield select((state: RootState) => state.auth);
if (token) {
message.loading('loading all roles...');
try {
const response = yield call(securityProxy.roles);
message.success('load all roles success!');
logger.log('[loadAllRoles]', 'response of load all roles is', response);
yield put(securityActions.loadAllRolesSuccess(response.data));
} catch (e) {
logger.warn('[loadAllRoles]', 'CATCH -> load all roles error', e);
message.error(toErrorMessage(e));
}
}
},
*getCurrentUser() {
const { token } = yield select((state: RootState) => state.auth);
if (token) {
message.loading('loading current user...');
try {
logger.log('[getCurrentUser]', 'get current user after rehydrate...');
const response = yield call(securityProxy.currentUser);
message.success('get current user success!');
logger.log('[getCurrentUser]', 'response of get current user is', response);
yield put(securityActions.getCurrentUserSuccess(response.data));
} catch (e) {