本文整理汇总了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));
})
示例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 }));
}
示例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
})
);
}
示例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();
}
});
示例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 }));
}
}
示例6:
.catch(e => store.dispatch(actions.coreError(e)));
示例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({
//.........这里部分代码省略.........