mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06:59 +00:00
fix: replace shopify error
This commit is contained in:
parent
3ab0bd18d0
commit
ff8098128d
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user