Skip to content

Commit

Permalink
chore: safe catch by verifying the appropriate error
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Dec 7, 2022
1 parent 9062b8e commit a00fe15
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/medusa/src/services/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,10 @@ class CartService extends TransactionBaseService {
)
.catch((err: Error) => {
// We only want to catch the errors related to not found items since we don't care if there is not item to update
if (!err.message?.endsWith("was not found")) {
if (
!(err instanceof MedusaError) ||
err.type !== MedusaError.Types.NOT_FOUND
) {
throw err
}
})
Expand Down Expand Up @@ -819,7 +822,10 @@ class CartService extends TransactionBaseService {
)
.catch((err: Error) => {
// We only want to catch the errors related to not found items since we don't care if there is not item to update
if (!err.message?.endsWith("was not found")) {
if (
!(err instanceof MedusaError) ||
err.type !== MedusaError.Types.NOT_FOUND
) {
throw err
}
})
Expand Down

0 comments on commit a00fe15

Please sign in to comment.