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:
+2
-2
@@ -512,7 +512,7 @@ moduleIntegrationTestRunner({
|
||||
const err = await service.create(data).catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.constraint).toBe("IDX_fulfillment_set_name_unique")
|
||||
expect(err.message).toContain("exists")
|
||||
})
|
||||
|
||||
it("should fail on creating a new fulfillment set with new service zones and new geo zones that are not valid", async function () {
|
||||
@@ -837,7 +837,7 @@ moduleIntegrationTestRunner({
|
||||
const err = await service.update(updateData).catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.constraint).toBe("IDX_fulfillment_set_name_unique")
|
||||
expect(err.message).toContain("exists")
|
||||
})
|
||||
|
||||
it("should update a collection of fulfillment sets and replace old service zones by new ones", async function () {
|
||||
|
||||
+2
-2
@@ -187,7 +187,7 @@ moduleIntegrationTestRunner({
|
||||
const err = await service.createServiceZones(data).catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.constraint).toBe("IDX_service_zone_name_unique")
|
||||
expect(err.message).toContain("exists")
|
||||
})
|
||||
|
||||
it("should fail on creating a service zone and new geo zones that are not valid", async function () {
|
||||
@@ -435,7 +435,7 @@ moduleIntegrationTestRunner({
|
||||
.catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.constraint).toBe("IDX_service_zone_name_unique")
|
||||
expect(err.message).toContain("exists")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ moduleIntegrationTestRunner({
|
||||
.catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.constraint).toBe("IDX_shipping_profile_name_unique")
|
||||
expect(err.message).toContain("exists")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user