forked from crowetic/commerce
Fix 500 when a product is not found (#880)
This commit is contained in:
parent
90aa798891
commit
d09aff1745
@ -21,7 +21,7 @@ export const withOperationCallback =
|
|||||||
const parse = ({ name, data }: Operation) => {
|
const parse = ({ name, data }: Operation) => {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'getProduct':
|
case 'getProduct':
|
||||||
productSchema.nullable().parse(data.product)
|
productSchema.optional().parse(data.product)
|
||||||
break
|
break
|
||||||
case 'getAllProducts':
|
case 'getAllProducts':
|
||||||
z.array(productSchema).parse(data.products)
|
z.array(productSchema).parse(data.products)
|
||||||
|
@ -34,7 +34,9 @@ export async function getStaticProps({
|
|||||||
const { products: relatedProducts } = await allProductsPromise
|
const { products: relatedProducts } = await allProductsPromise
|
||||||
|
|
||||||
if (!product) {
|
if (!product) {
|
||||||
throw new Error(`Product with slug '${params!.slug}' not found`)
|
return {
|
||||||
|
notFound: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user