feat: Improve how options are defined and handled for product (#7007)
* feat: Improve how options are defined and handled for product * fix: Updating option values supports passing without id
This commit is contained in:
@@ -13,7 +13,10 @@ export const dbErrorMapper = (err: Error) => {
|
||||
throw new MedusaError(MedusaError.Types.NOT_FOUND, err.message)
|
||||
}
|
||||
|
||||
if (err instanceof UniqueConstraintViolationException) {
|
||||
if (
|
||||
err instanceof UniqueConstraintViolationException ||
|
||||
(err as any).code === "23505"
|
||||
) {
|
||||
const info = getConstraintInfo(err)
|
||||
if (!info) {
|
||||
throw err
|
||||
@@ -27,7 +30,10 @@ export const dbErrorMapper = (err: Error) => {
|
||||
)
|
||||
}
|
||||
|
||||
if (err instanceof NotNullConstraintViolationException) {
|
||||
if (
|
||||
err instanceof NotNullConstraintViolationException ||
|
||||
(err as any).code === "23502"
|
||||
) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Cannot set field '${(err as any).column}' of ${upperCaseFirst(
|
||||
@@ -36,7 +42,10 @@ export const dbErrorMapper = (err: Error) => {
|
||||
)
|
||||
}
|
||||
|
||||
if (err instanceof InvalidFieldNameException) {
|
||||
if (
|
||||
err instanceof InvalidFieldNameException ||
|
||||
(err as any).code === "42703"
|
||||
) {
|
||||
const userFriendlyMessage = err.message.match(/(column.*)/)?.[0]
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
@@ -44,7 +53,10 @@ export const dbErrorMapper = (err: Error) => {
|
||||
)
|
||||
}
|
||||
|
||||
if (err instanceof ForeignKeyConstraintViolationException) {
|
||||
if (
|
||||
err instanceof ForeignKeyConstraintViolationException ||
|
||||
(err as any).code === "23503"
|
||||
) {
|
||||
const info = getConstraintInfo(err)
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_FOUND,
|
||||
|
||||
Reference in New Issue
Block a user