fix: propagate Shopify 404 through upload route so client retry triggers correctly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ export async function POST(req: NextRequest) {
|
|||||||
return NextResponse.json(result)
|
return NextResponse.json(result)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = err instanceof Error ? err.message : 'Erreur inconnue'
|
const message = err instanceof Error ? err.message : 'Erreur inconnue'
|
||||||
return NextResponse.json({ error: message }, { status: 500 })
|
const status = (err as { status?: number }).status === 404 ? 404 : 500
|
||||||
|
return NextResponse.json({ error: message }, { status })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,6 +161,12 @@ export async function uploadProductImage(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res.status === 404) {
|
||||||
|
const err = new Error(`Shopify upload error: 404 — product not found`) as Error & { status: number }
|
||||||
|
err.status = 404
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const body = await res.text()
|
const body = await res.text()
|
||||||
throw new Error(`Shopify upload error: ${res.status} — ${body}`)
|
throw new Error(`Shopify upload error: ${res.status} — ${body}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user