fix: handle case where product to be updated does not exist (#8897)

This commit is contained in:
Harminder Virk
2024-09-02 16:23:31 +05:30
committed by GitHub
parent 25367734c7
commit 0ce584029c
11 changed files with 128 additions and 0 deletions
@@ -35,6 +35,16 @@ export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateCustomerType & AdditionalData>,
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
) => {
const existingCustomer = await refetchCustomer(req.params.id, req.scope, [
"id",
])
if (!existingCustomer) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Customer with id "${req.params.id}" not found`
)
}
const { additional_data, ...rest } = req.validatedBody
await updateCustomersWorkflow(req.scope).run({