Skip to content

Commit

Permalink
feat: error handdling
Browse files Browse the repository at this point in the history
  • Loading branch information
duyet committed Nov 21, 2023
1 parent 9df24b2 commit aba3ce4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client'

import { useEffect } from 'react'

import { Button } from '@/components/ui/button'

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
useEffect(() => {
// Log the error to an error reporting service
console.error(error)
}, [error])

return (
<div>
<h2 className="font-medium">Something went wrong!</h2>
<p className="mb-5 font-light">Checking console for more details.</p>
<Button
variant="outline"
onClick={
// Attempt to recover by trying to re-render the segment
() => reset()
}
>
Try again
</Button>
</div>
)
}
1 change: 1 addition & 0 deletions app/overview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const revalidate = 5
export default async function Overview() {
noStore()

x
return (
<Tabs defaultValue="overview" className="space-y-4">
<div className="flex items-center justify-between space-y-2">
Expand Down

0 comments on commit aba3ce4

Please sign in to comment.