"use client";

import { useEffect } from 'react';

export const ClientErrorHandler = () => {
  useEffect(() => {
    console.log('🔥 CLIENT: Setting up global error handlers...');
    
    const handleError = (event: ErrorEvent) => {
      console.error('🔥 CLIENT ERROR:', event.error);
      console.error('🔥 CLIENT ERROR Stack:', event.error?.stack);
      console.error('🔥 CLIENT ERROR Message:', event.message);
      console.error('🔥 CLIENT ERROR Source:', event.filename, 'Line:', event.lineno);
    };
    
    const handleUnhandledRejection = (event: PromiseRejectionEvent) => {
      console.error('🔥 CLIENT UNHANDLED PROMISE REJECTION:', event.reason);
    };
    
    window.addEventListener('error', handleError);
    window.addEventListener('unhandledrejection', handleUnhandledRejection);
    
    return () => {
      window.removeEventListener('error', handleError);
      window.removeEventListener('unhandledrejection', handleUnhandledRejection);
    };
  }, []);
  
  return null;
}; 