fix: replace shopify error

This commit is contained in:
Victor Gerbrands 2023-05-02 16:14:57 +02:00
parent 3ab0bd18d0
commit ff8098128d
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { isShopifyError } from 'lib/type-guards';
import { isMedusaError } from 'lib/type-guards';
import { Cart, MedusaCart, MedusaProduct, Product, ProductCollection } from './types';
// const endpoint = `${process.env.MEDUSA_BACKEND_API!}`;
@ -34,7 +34,7 @@ export default async function medusaRequest(
body
};
} catch (e) {
if (isShopifyError(e)) {
if (isMedusaError(e)) {
throw {
status: e.status || 500,
message: e.message

View File

@ -1,4 +1,4 @@
export interface ShopifyErrorLike {
export interface MedusaErrorLike {
status: number;
message: Error;
}
@ -7,7 +7,7 @@ export const isObject = (object: unknown): object is Record<string, unknown> =>
return typeof object === 'object' && object !== null && !Array.isArray(object);
};
export const isShopifyError = (error: unknown): error is ShopifyErrorLike => {
export const isMedusaError = (error: unknown): error is MedusaErrorLike => {
if (!isObject(error)) return false;
if (error instanceof Error) return true;