Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error when webpage cannot be reached or parsed #930

Merged
merged 3 commits into from Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/lib/components/OpenWebSearchResults.svelte
Expand Up @@ -9,8 +9,8 @@
export let webSearchMessages: WebSearchUpdate[] = [];

$: sources = webSearchMessages.find((m) => m.sources)?.sources;
$: error = webSearchMessages.find((m) => m.messageType === "error");
$: loading = !sources && !error;
$: lastMessage = webSearchMessages.filter((m) => m.messageType !== "sources").slice(-1)[0];
$: loading = !sources && lastMessage.messageType !== "error";
</script>

<details
Expand Down Expand Up @@ -44,12 +44,10 @@
<dl class="leading-4">
<dd class="text-sm">Web Search</dd>
<dt class="flex items-center gap-1 truncate whitespace-nowrap text-[.82rem] text-gray-400">
{#if error}
{error.message}
{:else if sources}
{#if sources}
Completed
{:else}
{webSearchMessages[webSearchMessages.length - 1].message}
{lastMessage.message}
{/if}
</dt>
</dl>
Expand Down
1 change: 1 addition & 0 deletions src/lib/server/websearch/runWebSearch.ts
Expand Up @@ -128,6 +128,7 @@ export async function runWebSearch(
text = await parseWeb(link);
appendUpdate("Browsing webpage", [link]);
} catch (e) {
appendUpdate("Failed to parse webpage", [(e as Error).message, link], "error");
// ignore errors
}
}
Expand Down