feat(medusa): remove created reservations on subsequent failure for cart completion (#3554)
**What** - If cart completion fails after creating reservations, remove those reservations **Why** - To avoid hanging reservations if something fails at a later point
This commit is contained in:
@@ -4,6 +4,7 @@ export enum PostgresError {
|
||||
DUPLICATE_ERROR = "23505",
|
||||
FOREIGN_KEY_ERROR = "23503",
|
||||
SERIALIZATION_FAILURE = "40001",
|
||||
NULL_VIOLATION = "23502",
|
||||
}
|
||||
|
||||
export const formatException = (err): MedusaError => {
|
||||
@@ -43,6 +44,12 @@ export const formatException = (err): MedusaError => {
|
||||
err?.detail ?? err?.message
|
||||
)
|
||||
}
|
||||
case PostgresError.NULL_VIOLATION: {
|
||||
return new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Can't insert null value in field ${err?.column} on insert in table ${err?.table}`
|
||||
)
|
||||
}
|
||||
default:
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user