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


TypeScript actions.coreError方法代码示例

本文整理汇总了TypeScript中@nteract/core.actions.coreError方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.coreError方法的具体用法?TypeScript actions.coreError怎么用?TypeScript actions.coreError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@nteract/core.actions的用法示例。


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

示例1: catchError

        catchError(err => {
          // Turn the response headers into an object
          const arr: string[] = err.xhr.getAllResponseHeaders().split("\r\n");
          const headers: { [header: string]: string } = arr.reduce(
            (acc: { [header: string]: string }, current) => {
              const parts = current.split(": ");
              acc[parts[0]] = parts[1];
              return acc;
            },
            {}
          );

          // If we see the oauth scopes don't list gist, we know the problem is the token's access
          if (
            headers.hasOwnProperty("X-OAuth-Scopes") &&
            !headers["X-OAuth-Scopes"].includes("gist")
          ) {
            notificationSystem.addNotification({
              title: "Bad GitHub Token",
              message:
                "The gist API reports that the token doesn't have gist scopes 🤷‍♀️",
              dismissible: true,
              position: "tr",
              level: "error"
            });
            return of(
              actions.coreError(
                new Error("Current token doesn't allow for gists")
              )
            );
          }

          // When the GitHub API returns a 404 for POST'ing on the
          // /gists endpoint, it's a
          if (err.status > 500) {
            // Likely a GitHub API error
            notificationSystem.addNotification({
              title: "Gist publishing failed",
              message: "😩 GitHub API not feelin' good today",
              dismissible: true,
              position: "tr",
              level: "error"
            });
          }
          return of(actions.coreError(err));
        })
开发者ID:nteract,项目名称:nteract,代码行数:46,代码来源:github-publish.ts

示例2: dispatchKillKernel

export function dispatchKillKernel(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  const state = store.getState();
  const kernelRef = selectors.kernelRefByContentRef(state, ownProps);
  if (!kernelRef) {
    store.dispatch(actions.coreError(new Error("kernel not set")));
    return;
  }

  store.dispatch(actions.killKernel({ restarting: false, kernelRef }));
}
开发者ID:nteract,项目名称:nteract,代码行数:13,代码来源:menu.ts

示例3: dispatchRestartKernel

export function dispatchRestartKernel(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore,
  outputHandling: actions.RestartKernelOutputHandling
) {
  const state = store.getState();
  const kernelRef = selectors.kernelRefByContentRef(state, ownProps);

  if (!kernelRef) {
    store.dispatch(actions.coreError(new Error("kernel not set")));
    return;
  }

  store.dispatch(
    actions.restartKernel({
      outputHandling,
      kernelRef,
      contentRef: ownProps.contentRef
    })
  );
}
开发者ID:nteract,项目名称:nteract,代码行数:21,代码来源:menu.ts

示例4: catch

      remote.ipcMain.on("auth", (_event: Event, auth: string) => {
        try {
          const accessToken = JSON.parse(auth).access_token;
          store.dispatch(actions.setGithubToken(accessToken));

          const notificationSystem = selectors.notificationSystem(state);

          notificationSystem.addNotification({
            title: "Authenticated",
            message: "🔒",
            level: "info"
          });

          // We are now authenticated and can finally publish
          store.dispatch(actions.publishGist(ownProps));
        } catch (e) {
          store.dispatch(actions.coreError(e));
        } finally {
          win.close();
        }
      });
开发者ID:nteract,项目名称:nteract,代码行数:21,代码来源:menu.ts

示例5: dispatchInterruptKernel

export function dispatchInterruptKernel(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  const state = store.getState();

  const notificationSystem = selectors.notificationSystem(state);
  if (process.platform === "win32") {
    notificationSystem.addNotification({
      title: "Not supported in Windows",
      message: "Kernel interruption is not supported in Windows.",
      level: "error"
    });
  } else {
    const kernelRef = selectors.kernelRefByContentRef(state, ownProps);
    if (!kernelRef) {
      store.dispatch(actions.coreError(new Error("kernel not set")));
      return;
    }

    store.dispatch(actions.interruptKernel({ kernelRef }));
  }
}
开发者ID:nteract,项目名称:nteract,代码行数:23,代码来源:menu.ts

示例6:

 .catch(e => store.dispatch(actions.coreError(e)));
开发者ID:nteract,项目名称:nteract,代码行数:1,代码来源:menu.ts

示例7: mergeMap

    mergeMap((action: actions.PublishGist) => {
      const state = state$.value;

      const contentRef = action.payload.contentRef;
      if (!contentRef) {
        return empty();
      }

      // TODO: Switch GitHub publishing actions to content refs
      const content = selectors.content(state, { contentRef });
      // NOTE: This could save by having selectors for each model type
      //       have toDisk() selectors
      if (!content || content.type !== "notebook") {
        return empty();
      }

      const filepath = content.filepath;
      const notificationSystem = selectors.notificationSystem(state);

      const model = content.model;

      const notebookString = selectors.notebook.asString(model);
      const gistId = selectors.notebook.gistId(model);

      // Allow falling back on the GITHUB_TOKEN environment variable
      const githubToken = state.app.get("githubToken");

      if (githubToken == null) {
        return of(
          actions.coreError(
            new Error("need a github token in order to publish")
          )
        );
      }

      if (gistId && typeof gistId !== "string") {
        return of(
          actions.coreError(new Error("gist id in notebook is not a string"))
        );
      }

      // We are updating, so we require both a gist Id and a github token
      // If this doesn't happen to be our originally gisted notebook,
      // we should likely fork and publish
      //
      // TODO: Check to see if the token matches that of the username listed
      //       in the notebook itself
      if (gistId) {
        notificationSystem.addNotification({
          title: "Updating Gist...",
          message: "💖📓💖",
          dismissible: true,
          position: "tr",
          level: "success"
        });
      } else {
        notificationSystem.addNotification({
          title: "Publishing a New Gist...",
          message: "✨📓✨",
          dismissible: true,
          position: "tr",
          level: "success"
        });
      }

      const filename = filepath ? path.parse(filepath).base : "Untitled.ipynb";
      const files: GithubFiles = {
        [filename]: { content: notebookString }
      };

      return publishGist(
        { files, description: filename, public: false },
        githubToken,
        gistId
      ).pipe(
        mergeMap(xhr => {
          const notificationSystem = selectors.notificationSystem(state$.value);

          const { id, login } = xhr.response;

          // NOTE: One day we need to make this part of our proper store
          //       instead of hidden side effects
          notificationSystem.addNotification({
            title: "Gist uploaded",
            message: "📓 📢",
            dismissible: true,
            position: "tr",
            level: "success",
            action: {
              label: "Open Gist",
              callback() {
                shell.openExternal(`https://nbviewer.jupyter.org/${id}`);
              }
            }
          });

          // TODO: Turn this into one action that does both, even if its
          // sometimes a no-op
          return of(
            actions.overwriteMetadataField({
//.........这里部分代码省略.........
开发者ID:nteract,项目名称:nteract,代码行数:101,代码来源:github-publish.ts


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