From 2e763f52a4fca3db2747ea358ebdfbb7f4c87a7d Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Wed, 11 Sep 2024 15:15:49 -0700 Subject: [PATCH] Show errors in filing issues/PRs --- js/packages/repo-quest/src/index.tsx | 29 ++++++++++++++++++++++++++-- rs/crates/repo-quest/src/github.rs | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/js/packages/repo-quest/src/index.tsx b/js/packages/repo-quest/src/index.tsx index cf1194b..502f351 100644 --- a/js/packages/repo-quest/src/index.tsx +++ b/js/packages/repo-quest/src/index.tsx @@ -9,6 +9,7 @@ import { events, type QuestConfig, type QuestState, + type Result, type Stage, type StageState, type StateDescriptor, @@ -88,6 +89,17 @@ let ErrorView: React.FC<{ message: string; action: string }> = ({ return null; }; +async function tryAwait( + promise: Promise>, + action: string, + setMessage: (message: ErrorMessage) => void +) { + let result = await promise; + if (result.status === "error") { + setMessage({ action, message: result.error }); + } +} + let GithubLoader = () => ( {token => @@ -343,6 +355,7 @@ let StageView: React.FC<{ state: QuestState; }> = ({ index, stage, state }) => { let loader = useContext(Loader.context)!; + let setMessage = useContext(ErrorContext)!; return (
  • @@ -354,7 +367,13 @@ let StageView: React.FC<{