'use client'; import { Button } from '@/components/ui/button'; import { AlertTriangle, ChevronLeft, RefreshCw } from 'lucide-react'; import React, { Component, ReactNode } from 'react'; interface Props { children: ReactNode; fallback?: ReactNode; showBackButton?: boolean; backButtonText?: string; backButtonAction?: () => void; } interface State { hasError: boolean; error?: Error; } export class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error('ErrorBoundary caught an error:', error, errorInfo); // シリアライゼーションエラーの詳細解析 if (error.message.includes('Only plain objects')) { console.error('[SERIALIZATION_ERROR] シリアライゼーションエラーの詳細:'); console.error('[SERIALIZATION_ERROR] Error message:', error.message); console.error('[SERIALIZATION_ERROR] Error stack:', error.stack); console.error('[SERIALIZATION_ERROR] Component stack:', errorInfo.componentStack); // エラーダイジェストが含まれている場合の解析 if ('digest' in error) { console.error('[SERIALIZATION_ERROR] Error digest:', (error as Error & { digest?: string }).digest); } } } handleReset = () => { this.setState({ hasError: false, error: undefined }); }; render() { if (this.state.hasError) { if (this.props.fallback) { return <>{this.props.fallback}; } return (

エラーが発生しました

申し訳ございません。予期しないエラーが発生しました。 {this.state.error?.message && {this.state.error.message}}

{this.props.showBackButton && ( )}
); } return this.props.children; } }