"use client"; import React, { createContext, useContext, useState } from "react"; interface ErrorContextProps { error: Error | null; humanMessage?: string; setError: (error: Error, humanMessage?: string) => void; } const ErrorContext = createContext(undefined); export const useError = () => { const context = useContext(ErrorContext); if (!context) { throw new Error("useError must be used within an ErrorProvider"); } return context; }; interface ErrorProviderProps { children: React.ReactNode; } export const ErrorProvider: React.FC = ({ children }) => { const [error, setError] = useState(null); const [humanMessage, setHumanMessage] = useState(); const declareError = (error, humanMessage?) => { setError(error); setHumanMessage(humanMessage); }; return ( {children} ); };