Created
March 19, 2025 10:38
-
-
Save sommeeeer/0fc8ce7e5fffaf4a1e6f125168f12b65 to your computer and use it in GitHub Desktop.
error-trigger in next
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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