本文整理汇总了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) {