import { Check, ChevronDown, Copy } from "lucide-react"; import * as React from "react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; interface StackTraceProps { error?: string; stacktrace?: string[]; className?: string; } export function StackTrace({ error, stacktrace, className }: StackTraceProps) { const [expanded, setExpanded] = React.useState(false); const [copied, setCopied] = React.useState(false); if (!error && (!stacktrace || stacktrace.length === 0)) { return null; } const fullText = [error, ...(stacktrace || [])].filter(Boolean).join("\n"); const handleCopy = () => { navigator.clipboard.writeText(fullText); setCopied(true); setTimeout(() => setCopied(false), 2000); }; return (
{error || "Unknown error"}
{stacktrace.map((line, i) => (
{formatStackLine(line)}
))}