Skip to content

Commit

Permalink
clients/web: handle 404 response in webhook breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Oct 28, 2024
1 parent eb625db commit c06357d
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import CopyToClipboardButton from '@/components/CopyToClipboardButton/CopyToClipboardButton'
import { getServerSideAPI } from '@/utils/api/serverside'
import { ResponseError, WebhookEndpoint } from '@polar-sh/sdk'
import { notFound } from 'next/navigation'
import {
BreadcrumbLink,
BreadcrumbPageParams,
Expand All @@ -12,7 +14,17 @@ export default async function BreadcrumbPage({
params: BreadcrumbPageParams & { id: string }
}) {
const api = await getServerSideAPI()
const webhook = await api.webhooks.getWebhookEndpoint({ id: params.id })

let webhook: WebhookEndpoint
try {
webhook = await api.webhooks.getWebhookEndpoint({ id: params.id })
} catch (err) {
if (err instanceof ResponseError && err.response.status === 404) {
notFound()
}
throw err
}

return (
<>
<BreadcrumbSeparator />
Expand Down

0 comments on commit c06357d

Please sign in to comment.