"use client"; import { useEffect } from 'react' import { useRouter } from 'next/navigation'; import { emitAuthExpired } from "@/utils/auth/auth-events"; //https://nextjs.org/docs/app/api-reference/file-conventions/error export default function Error({ error, retry }: { retry: () => void; error: Error & { digest?: string }; }) { const router = useRouter(); let msg = "There was an issue with our storefront. This could be a temporary issue, please try your action again."; if(error.name === 'UnauthorizedError') { msg = "Authorization Bearer token is required. Will redirect to Login page."; } const clickHandler = () => { if(error.name === 'UnauthorizedError') { router.push('/customer/login') } else { retry(); } }; useEffect(() => { if (error.name === "UnauthorizedError") { emitAuthExpired(); } // Log the error to an error reporting service console.error(error) }, [error]) return (
{msg}