import React, { useState } from 'react'; import { TError } from 'librechat-data-provider'; type ProviderValue = { error: TError; setError: React.Dispatch>; }; const ApiErrorBoundaryContext = React.createContext(undefined); export const ApiErrorBoundaryProvider = ({ value, children, }: { value: ProviderValue; children: React.ReactNode; }) => { const [error, setError] = useState(false); return ( {children} ); }; export const useApiErrorBoundary = () => { const context = React.useContext(ApiErrorBoundaryContext); if (context === undefined) { throw new Error('useApiErrorBoundary must be used inside ApiErrorBoundaryProvider'); } return context; };