diff --git a/lib/bigcommerce/cart/use-add-item.tsx b/lib/bigcommerce/cart/use-add-item.tsx index fa8bb8b46..36fbec7d2 100644 --- a/lib/bigcommerce/cart/use-add-item.tsx +++ b/lib/bigcommerce/cart/use-add-item.tsx @@ -1,5 +1,6 @@ import { useCallback } from 'react' -import { HookFetcher } from '@lib/commerce/utils/types' +import type { HookFetcher } from '@lib/commerce/utils/types' +import { CommerceError } from '@lib/commerce/utils/errors' import useCartAddItem from '@lib/commerce/cart/use-add-item' import type { ItemBody, AddItemBody } from '../api/cart' import useCart, { Cart } from './use-cart' @@ -20,9 +21,9 @@ export const fetcher: HookFetcher = ( item.quantity && (!Number.isInteger(item.quantity) || item.quantity! < 1) ) { - throw new Error( - 'The item quantity has to be a valid integer greater than 0' - ) + throw new CommerceError({ + message: 'The item quantity has to be a valid integer greater than 0', + }) } return fetch({ diff --git a/lib/bigcommerce/cart/use-update-item.tsx b/lib/bigcommerce/cart/use-update-item.tsx index bcad7ab3a..875c241f8 100644 --- a/lib/bigcommerce/cart/use-update-item.tsx +++ b/lib/bigcommerce/cart/use-update-item.tsx @@ -1,6 +1,7 @@ import { useCallback } from 'react' import debounce from 'lodash.debounce' -import { HookFetcher } from '@lib/commerce/utils/types' +import type { HookFetcher } from '@lib/commerce/utils/types' +import { CommerceError } from '@lib/commerce/utils/errors' import useCartUpdateItem from '@lib/commerce/cart/use-update-item' import type { ItemBody, UpdateItemBody } from '../api/cart' import { fetcher as removeFetcher } from './use-remove-item' @@ -24,7 +25,9 @@ export const fetcher: HookFetcher = ( return removeFetcher(null, { itemId }, fetch) } } else if (item.quantity) { - throw new Error('The item quantity has to be a valid integer') + throw new CommerceError({ + message: 'The item quantity has to be a valid integer', + }) } return fetch({ diff --git a/lib/bigcommerce/use-login.tsx b/lib/bigcommerce/use-login.tsx index d2b86a827..d0465cc5a 100644 --- a/lib/bigcommerce/use-login.tsx +++ b/lib/bigcommerce/use-login.tsx @@ -1,5 +1,6 @@ import { useCallback } from 'react' -import { HookFetcher } from '@lib/commerce/utils/types' +import type { HookFetcher } from '@lib/commerce/utils/types' +import { CommerceError } from '@lib/commerce/utils/errors' import useCommerceLogin from '@lib/commerce/use-login' import type { LoginBody } from './api/customers/login' @@ -16,9 +17,10 @@ export const fetcher: HookFetcher = ( fetch ) => { if (!(email && password)) { - throw new Error( - 'A first name, last name, email and password are required to login' - ) + throw new CommerceError({ + message: + 'A first name, last name, email and password are required to login', + }) } return fetch({ diff --git a/lib/bigcommerce/use-signup.tsx b/lib/bigcommerce/use-signup.tsx index 2756bdf09..709d3f2cf 100644 --- a/lib/bigcommerce/use-signup.tsx +++ b/lib/bigcommerce/use-signup.tsx @@ -1,6 +1,6 @@ import { useCallback } from 'react' -import { CommerceError } from '@lib/commerce/utils/errors' import type { HookFetcher } from '@lib/commerce/utils/types' +import { CommerceError } from '@lib/commerce/utils/errors' import useCommerceSignup from '@lib/commerce/use-signup' import type { SignupBody } from './api/customers/signup'