chore: issue #299: implemented DUPLICATE_ERROR in places necessary (#314)

This commit is contained in:
Abraham Ugbeshe
2021-07-22 17:28:12 +01:00
committed by GitHub
parent 8783de17cd
commit 8c26a5fd88
7 changed files with 8 additions and 8 deletions

View File

@@ -454,7 +454,7 @@ class OrderService extends BaseService {
const exists = await this.existsByCartId(cart.id)
if (exists) {
throw new MedusaError(
MedusaError.Types.INVALID_ARGUMENT,
MedusaError.Types.DUPLICATE_ERROR,
"Order from cart already exists"
)
}

View File

@@ -169,7 +169,7 @@ class ProductVariantService extends BaseService {
if (variantExists) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
MedusaError.Types.DUPLICATE_ERROR,
`Variant with title ${variantExists.title} with provided options already exists`
)
}

View File

@@ -492,7 +492,7 @@ class ProductService extends BaseService {
if (product.options.find(o => o.title === optionTitle)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
MedusaError.Types.DUPLICATE_ERROR,
`An option with the title: ${optionTitle} already exists`
)
}
@@ -631,7 +631,7 @@ class ProductService extends BaseService {
if (!productOption) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Option with id: ${optionId} deos not exists`
`Option with id: ${optionId} does not exists`
)
}

View File

@@ -328,7 +328,7 @@ class RegionService extends BaseService {
if (country.region_id && country.region_id !== regionId) {
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
MedusaError.Types.DUPLICATE_ERROR,
`${country.name} already exists in ${country.name}, delete it in that region before adding it`
)
}

View File

@@ -523,7 +523,7 @@ class ShippingOptionService extends BaseService {
if (option.requirements.find(r => r.type === validatedReq.type)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
MedusaError.Types.DUPLICATE_ERROR,
`A requirement with type: ${validatedReq.type} already exists`
)
}

View File

@@ -189,7 +189,7 @@ class StoreService extends BaseService {
if (store.currencies.map(c => c.code).includes(curr.code.toLowerCase())) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
MedusaError.Types.DUPLICATE_ERROR,
`Currency already added`
)
}

View File

@@ -440,7 +440,7 @@ class SwapService extends BaseService {
if (swap.cart_id) {
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
MedusaError.Types.DUPLICATE_ERROR,
"A cart has already been created for the swap"
)
}