当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript helpers.toErrorMessage函数代码示例

本文整理汇总了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));
    }
  }
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:30,代码来源:auth.redux.ts

示例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));
    }
  }
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:25,代码来源:content.redux.ts

示例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) {
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:security.redux.ts


注:本文中的@asuna-admin/helpers.toErrorMessage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。