Skip to content

Instantly share code, notes, and snippets.

@sommeeeer
Created March 19, 2025 10:38
Show Gist options
  • Select an option

  • Save sommeeeer/0fc8ce7e5fffaf4a1e6f125168f12b65 to your computer and use it in GitHub Desktop.

Select an option

Save sommeeeer/0fc8ce7e5fffaf4a1e6f125168f12b65 to your computer and use it in GitHub Desktop.
error-trigger in next
'use client'
import { Bug } from 'lucide-react'
import { useState } from 'react'
export const ErrorTrigger = ({
message = 'An error occurred',
}: {
message?: string
}) => {
const [error, setError] = useState(false)
if (error) throw new Error(message)
return (
<button
title="Trigger an error"
className="bg-red-950 text-red-500 rounded p-1 leading-none font-semibold text-sm hover:bg-red-900 transition"
onClick={() => setError(true)}
>
<Bug size={16} />
</button>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment