mirror of
https://github.com/vercel/commerce.git
synced 2025-07-08 05:41:22 +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';
|
import { Cart, MedusaCart, MedusaProduct, Product, ProductCollection } from './types';
|
||||||
|
|
||||||
// const endpoint = `${process.env.MEDUSA_BACKEND_API!}`;
|
// const endpoint = `${process.env.MEDUSA_BACKEND_API!}`;
|
||||||
@ -34,7 +34,7 @@ export default async function medusaRequest(
|
|||||||
body
|
body
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isShopifyError(e)) {
|
if (isMedusaError(e)) {
|
||||||
throw {
|
throw {
|
||||||
status: e.status || 500,
|
status: e.status || 500,
|
||||||
message: e.message
|
message: e.message
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export interface ShopifyErrorLike {
|
export interface MedusaErrorLike {
|
||||||
status: number;
|
status: number;
|
||||||
message: Error;
|
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);
|
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 (!isObject(error)) return false;
|
||||||
|
|
||||||
if (error instanceof Error) return true;
|
if (error instanceof Error) return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user