Skip to content

Commit

Permalink
Merge pull request #200 from cozy/feat/errorMsg
Browse files Browse the repository at this point in the history
feat: Add explicit error msg if no VaultProvider
  • Loading branch information
JF-Cozy authored May 17, 2022
2 parents 0eee6c6 + a4b4662 commit c353df7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/VaultContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ const withVaultClient = BaseComponent => {

const useVaultClient = () => {
const ctx = useContext(VaultContext)

if (!ctx) {
throw new Error('useVaultClient must be used within a VaultProvider')
}
return ctx.vaultClient
}

Expand Down

0 comments on commit c353df7

Please sign in to comment.