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


TypeScript farmbot-toastr.error函数代码示例

本文整理汇总了TypeScript中farmbot-toastr.error函数的典型用法代码示例。如果您正苦于以下问题:TypeScript error函数的具体用法?TypeScript error怎么用?TypeScript error使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了error函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

  return function (dispatch, getState) {
    const resources = getState().resources;
    const { weeks, dailyOffsetMs, selectedSequenceUUID, currentRegimen } =
      resources.consumers.regimens;

    // If the user hasn't clicked a regimen, initialize one for them.
    if (currentRegimen) {
      // Proceed only if they selected a sequence from the drop down.
      if (selectedSequenceUUID) {
        const sequence =
          findSequence(resources.index, selectedSequenceUUID).body;
        const groupedItems = weeks.length > 0 ?
          groupRegimenItemsByWeek(weeks, dailyOffsetMs, sequence) : undefined;
        // Proceed only if days are selected in the scheduler.
        if (groupedItems && groupedItems.length > 0) {
          const regimen = findRegimen(resources.index, currentRegimen);
          const clonedRegimen = defensiveClone(regimen).body;
          clonedRegimen.regimen_items = clonedRegimen.regimen_items.concat(groupedItems);
          const varData = resources.index.sequenceMetas[selectedSequenceUUID];
          clonedRegimen.body = mergeVariableDeclarations(varData, regimen.body.body);
          dispatch(overwrite(regimen, clonedRegimen));
        } else {
          return error(t("No day(s) selected."));
        }
      } else {
        return error(t("Select a sequence from the dropdown first."), t("Error"));
      }
    } else {
      return error(t("Select a regimen first or create one."));
    }
  };
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:31,代码来源:actions.ts

示例2: function

  return function (dispatch, getState) {
    let res = getState().resources;
    let { weeks, dailyOffsetMs, selectedSequenceUUID, currentRegimen } =
      res.consumers.regimens;

    // If the user hasn't clicked a regimen, initialize one for them.
    if (currentRegimen) {
      // Proceed only if they selected a sequence from the drop down.
      if (selectedSequenceUUID) {
        let seq = findSequence(res.index, selectedSequenceUUID).body;
        const regimenItems = groupRegimenItemsByWeek(weeks, dailyOffsetMs, seq);
        // Proceed only if days are selcted in the scheduler.
        if (regimenItems.length > 0) {
          let reg = findRegimen(res.index, currentRegimen);
          let update = defensiveClone(reg).body;
          update.regimen_items = update.regimen_items.concat(regimenItems);
          dispatch(overwrite(reg, update));
        } else {
          return error(t("No day(s) selected."));
        }
      } else {
        return error(t("Select a sequence from the dropdown first."));
      }
    } else {
      return error(t("Select a regimen first or create one."));
    }
  };
开发者ID:MrChristofferson,项目名称:Farmbot-Web-API,代码行数:27,代码来源:actions.ts

示例3: error

 .catch((ferror) => {
   error(t("Could not download firmware update information."));
   dispatch({
     type: "FETCH_OS_UPDATE_INFO_ERROR",
     payload: ferror
   });
 });
开发者ID:creimers,项目名称:Farmbot-Web-API,代码行数:7,代码来源:actions.ts

示例4: responseRejected

export function responseRejected(x: SafeError | undefined) {

  if (x && isSafeError(x)) {
    let a = ![451, 401, 422].includes(x.response.status);
    let b = x.response.status > 399;
    // Openfarm API was sending too many 404's.
    let c = !_.get(x, "response.config.url", "").includes("openfarm.cc/");

    if (a && b && c) {
      setTimeout(() => {
        // Explicitly throw error so error reporting tool will save it.
        let msg = `Bad response: ${x.response.status} ${JSON.stringify(x.response)}`;
        throw new Error(msg);
      }, 1);
    }
    switch (x.response.status) {
      case 404:
        // Log 404's, but don't generate any noise for the user.
        break;
      case 500:
        error(t("Unexpected error occurred, we've been notified of the problem."));
        break;
      case 451:
        // DONT REFACTOR: I want to use alert() because it's blocking.
        alert(t("The terms of service have recently changed. You must " +
          "accept the new terms of service to continue using the site."));
        window.location.href = "/tos_update.html";
        break;
    }
    return Promise.reject(x);
  } else {
    console.warn("GOT MALFORMED HTTP REJECTION?? This shouldn't happen!");
    return Promise.reject(x);
  }
}
开发者ID:creimers,项目名称:Farmbot-Web-API,代码行数:35,代码来源:interceptors.ts

示例5: error

 .catch((ferror) => {
   !options.beta &&
     error(t("Could not download FarmBot OS update information."));
   dispatch({
     type: options.beta
       ? "FETCH_BETA_OS_UPDATE_INFO_ERROR"
       : "FETCH_OS_UPDATE_INFO_ERROR",
     payload: ferror
   });
 });
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:10,代码来源:actions.ts

示例6: findResource

 function findResource(i: ResourceIndex, u: string) {
   assertUuid(r, u);
   let result = i.references[u];
   if (result && isTaggedResource(result) && sanityCheck(result)) {
     return result as TaggedResource;
   } else {
     error("Resource error");
     throw new Error(`Tagged resource ${r} was not found or malformed: ` +
       JSON.stringify(result));
   }
 };
开发者ID:creimers,项目名称:Farmbot-Web-API,代码行数:11,代码来源:selectors.ts

示例7: showLogOnScreen

export function showLogOnScreen(log: Log) {
  switch (log.type) {
    case "success":
      return success(log.message, t(TITLE));
    case "warn":
      return warning(log.message, t(TITLE));
    case "busy":
    case "error":
      return error(log.message, t(TITLE));
    case "fun":
    case "info":
    default:
      return info(log.message, t(TITLE));
  }
}
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:15,代码来源:connect_device.ts

示例8: showLogOnScreen

export function showLogOnScreen(log: Log) {
  switch (log.type) {
    case MessageType.success:
      return success(log.message, t(TITLE));
    case MessageType.warn:
      return warning(log.message, t(TITLE));
    case MessageType.busy:
    case MessageType.error:
      return error(log.message, t(TITLE));
    case MessageType.fun:
    case MessageType.info:
    default:
      return info(log.message, t(TITLE));
  }
}
开发者ID:FarmBot,项目名称:Farmbot-Web-API,代码行数:15,代码来源:connect_device.ts

示例9: maybeShowLog

function maybeShowLog(log: Log) {
  let chanList = _.get(log, CHANNELS, ["ERROR FETCHING CHANNELS"]);
  let t = log.meta.type as ALLOWED_MESSAGE_TYPES;
  const TITLE = "New message from bot";
  if (chanList.includes(TOAST)) {
    switch (t) {
      case "success":
        return success(log.message, TITLE);
      case "busy":
      case "warn":
      case "error":
        return error(log.message, TITLE);
      case "fun":
      case "info":
      default:
        return info(log.message, TITLE);
    }
  }
}
开发者ID:creimers,项目名称:Farmbot-Web-API,代码行数:19,代码来源:actions.ts

示例10: responseRejected

export function responseRejected(x: SafeError | undefined) {
  if (x && isSafeError(x)) {
    dispatchNetworkUp("user.api", undefined, "isSafeError() REST error");
    const a = ![451, 401, 422].includes(x.response.status);
    const b = x.response.status > 399;
    // Openfarm API was sending too many 404's.
    const c = !get(x, "response.config.url", "").includes("openfarm.cc/");
    if (a && b && c) {
      setTimeout(() => {
        // Explicitly throw error so error reporting tool will save it.
        const msg = `Bad response: ${x.response.status} ${JSON.stringify(x.response)}`;
        throw new Error(msg);
      }, 1);
    }
    switch (x.response.status) {
      case 401:
        isLocalRequest(x) && Session.clear();
        break;
      case 404:
        // Log 404's, but don't generate any noise for the user.
        break;
      case 500:
        error(t("Unexpected error occurred, we've been notified of the problem."));
        break;
      case 451:
        // DONT REFACTOR: I want to use alert() because it's blocking.
        ONLY_ONCE && alert(t(Content.TOS_UPDATE));
        ONLY_ONCE = false;
        window.location.assign("/tos_update");
        break;
    }
    return Promise.reject(x);
  } else {
    dispatchNetworkDown("user.api", undefined, "responseRejected");
    return Promise.reject(x);
  }
}
开发者ID:FarmBot,项目名称:Farmbot-Web-API,代码行数:37,代码来源:interceptors.ts


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