From f866591da206cab89a56e802319cc23a4c4d2818 Mon Sep 17 00:00:00 2001 From: Lukas <lukas.budginas@gmail.com> Date: Thu, 12 Dec 2024 14:44:44 +0200 Subject: [PATCH] Update other contexts error messages --- contexts/AddressesContext.tsx | 2 +- contexts/HeadBlockContext.tsx | 2 +- contexts/HiveChainContext.tsx | 2 +- contexts/OperationsTypesContext.tsx | 12 +++++++++++- contexts/UserSettingsContext.tsx | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/contexts/AddressesContext.tsx b/contexts/AddressesContext.tsx index e3145df9..029a825a 100644 --- a/contexts/AddressesContext.tsx +++ b/contexts/AddressesContext.tsx @@ -19,7 +19,7 @@ export const useAddressesContext = () => { const context = useContext(AddressesContext); if (context === undefined) { - throw new Error("hook must be used inside it`s context"); + throw new Error("useAddressesContext must be used inside it`s context"); } return context; diff --git a/contexts/HeadBlockContext.tsx b/contexts/HeadBlockContext.tsx index d9bd1660..54b7b448 100644 --- a/contexts/HeadBlockContext.tsx +++ b/contexts/HeadBlockContext.tsx @@ -20,7 +20,7 @@ export const HeadBlockContext = createContext<IHeadBlockContext | undefined>( export const useHeadBlockNumber = () => { const context = useContext(HeadBlockContext); if (context === undefined) { - throw new Error("hook must be used inside it`s context"); + throw new Error("useHeadBlockNumber must be used inside it`s context"); } return context; diff --git a/contexts/HiveChainContext.tsx b/contexts/HiveChainContext.tsx index 64acf709..161c32da 100644 --- a/contexts/HiveChainContext.tsx +++ b/contexts/HiveChainContext.tsx @@ -14,7 +14,7 @@ export const useHiveChainContext = () => { const context = useContext(HiveChainContext); if (context === undefined) { - throw new Error("hook must be used inside it`s context"); + throw new Error("useHiveChainContext must be used inside it`s context"); } return context; diff --git a/contexts/OperationsTypesContext.tsx b/contexts/OperationsTypesContext.tsx index 9169cb1d..60730568 100644 --- a/contexts/OperationsTypesContext.tsx +++ b/contexts/OperationsTypesContext.tsx @@ -11,7 +11,17 @@ export const OperationTypesContext = createContext<OperationTypesContextType>({ operationsTypes: undefined, }); -export const useOperationTypesContext = () => useContext(OperationTypesContext); +export const useOperationTypesContext = () => { + const context = useContext(OperationTypesContext); + + if (context === undefined) { + throw new Error( + "useOperationTypesContext must be used inside it`s context" + ); + } + + return context; +}; export const OperationTypesContextProvider: React.FC<{ children: React.ReactNode; diff --git a/contexts/UserSettingsContext.tsx b/contexts/UserSettingsContext.tsx index 2809f89e..0a990887 100644 --- a/contexts/UserSettingsContext.tsx +++ b/contexts/UserSettingsContext.tsx @@ -20,7 +20,7 @@ export const useUserSettingsContext = () => { const context = useContext(UserSettingsContext); if (context === undefined) { - throw new Error("hook must be used inside it`s context"); + throw new Error("useUserSettingsContext must be used inside it`s context"); } return context; -- GitLab