Skip to content

Commit

Permalink
fix: better error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Oct 24, 2024
1 parent 7cf9d0d commit e9d8e0a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/app/src/components/entry-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,26 @@ export function EntryForm({ onFormSubmit, entry }: EntryFormProps) {
if (email) {
setIsProcessingEmail(true);
form.handleSubmit(async (e) => {
const result = await processEmail(e, email.contents)
setProcessedResult(result)
const slug = "drafts/"+form.getValues("slug");
const w = await createInputWorker(slug)
let result;
try {
result = await processEmail(e, email.contents)
} catch (e) {
setProcessedResult({
error: true,
matches: [],
message: `Failed to process email: ${e}`,
})
}
try {
const slug = "drafts/"+form.getValues("slug");
const w = await createInputWorker(slug)
const input = await generateInputFromEmail(w, slug, email.contents, {})
console.log("input", input)
if (result) setProcessedResult(result)
} catch (e) {
setProcessedResult({
...result,
error: true,
matches: [],
message: `Failed to generate circuit input: ${e}`,
})
}
Expand Down

0 comments on commit e9d8e0a

Please sign in to comment.