feat: Normalize known DB errors to a MedusaError when possible (#6922)

Before we would swallow the error and return a generic error to the user. This will provide more information to the caller if it is one of the known errors.
This commit is contained in:
Stevche Radevski
2024-04-04 19:12:59 +00:00
committed by GitHub
parent e944a627f0
commit 20e8df914e
14 changed files with 282 additions and 169 deletions
@@ -106,7 +106,7 @@ moduleIntegrationTestRunner({
],
}
await expect(service.create(customerData)).rejects.toThrow(
"A default shipping address already exists"
/Customer address with customer_id: .*? already exists./
)
})
@@ -727,7 +727,9 @@ moduleIntegrationTestRunner({
country_code: "US",
is_default_shipping: true,
})
).rejects.toThrow("A default shipping address already exists")
).rejects.toThrow(
/Customer address with customer_id: .*? already exists./
)
})
it("should only be possible to add one default billing address per customer", async () => {
@@ -761,7 +763,9 @@ moduleIntegrationTestRunner({
country_code: "US",
is_default_billing: true,
})
).rejects.toThrow("A default billing address already exists")
).rejects.toThrow(
/Customer address with customer_id: .*? already exists./
)
})
})
@@ -899,7 +903,9 @@ moduleIntegrationTestRunner({
await expect(
service.updateAddresses(address.id, { is_default_shipping: true })
).rejects.toThrow("A default shipping address already exists")
).rejects.toThrow(
/Customer address with customer_id: .*? already exists./
)
})
})