Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Refactor error codes names

Aleksander Spyraefd50cadd979
diff --git a/saleor/graphql/core/utils/error_codes.py b/saleor/graphql/core/utils/error_codes.py
index 884ac37975..1a461606a6 100644
--- a/saleor/graphql/core/utils/error_codes.py
+++ b/saleor/graphql/core/utils/error_codes.py
@@ -78,18 +78,17 @@ class MenuErrorCode(Enum):
class OrderErrorCode(Enum):
CANNOT_CANCEL_FULFILLMENT = "cannot_cancel_fulfillment"
CANNOT_CANCEL_ORDER = "cannot_cancel_order"
+ CANNOT_DELETE = "cannot_delete"
+ CANNOT_REFUND = "cannot_refund"
CAPTURE_INACTIVE_PAYMENT = "capture_inactive_payment"
- DELETE_LINE_NON_DRAFT_ORDER = "delete_line_non_draft_order"
- DELETE_NON_DRAFT_ORDER = "delete_non_draft_order"
EDIT_NON_DRAFT_ORDER = "edit_non_draft_order"
FULFILL_ORDER_LINE = "fulfill_order_line"
ORDER_INVALID_SHIPPING_METHOD = "order_invalid_shipping_method"
- ORDER_NO_PAYMENT = "order_no_payment"
ORDER_NO_PRODUCTS = "order_without_products"
ORDER_NO_SHIPPING_ADDRESS = "order_no_shipping_address"
- QUANTITY_LESS_THAN_ONE = "quantity_less_than_one"
- REFUND_MANUAL_PAYMENT = "refund_manual_payment"
+ PAYMENT_MISSING = "payment_missing"
VOID_INACTIVE_PAYMENT = "void_inactive_payment"
+ ZERO_QUANTITY = "zero_quantity"
class CommonErrorCode(Enum):
diff --git a/saleor/graphql/order/bulk_mutations/draft_orders.py b/saleor/graphql/order/bulk_mutations/draft_orders.py
index a96be4aa85..d2238f7364 100644
--- a/saleor/graphql/order/bulk_mutations/draft_orders.py
+++ b/saleor/graphql/order/bulk_mutations/draft_orders.py
@@ -24,7 +24,7 @@ class DraftOrderBulkDelete(ModelBulkDeleteMutation):
{
"id": ValidationError(
"Cannot delete non-draft orders.",
- code=OrderErrorCode.DELETE_NON_DRAFT_ORDER,
+ code=OrderErrorCode.CANNOT_DELETE,
)
}
)
@@ -48,7 +48,7 @@ class DraftOrderLinesBulkDelete(ModelBulkDeleteMutation):
{
"id": ValidationError(
"Cannot delete line for non-draft orders.",
- code=OrderErrorCode.DELETE_LINE_NON_DRAFT_ORDER,
+ code=OrderErrorCode.CANNOT_DELETE,
)
}
)
diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.py
index 995522fc13..36236c0ff6 100644
--- a/saleor/graphql/order/mutations/draft_orders.py
+++ b/saleor/graphql/order/mutations/draft_orders.py
@@ -312,8 +312,8 @@ class DraftOrderLinesCreate(BaseMutation):
raise ValidationError(
{
"quantity": ValidationError(
- "Ensure this value is greater than or equal to 1.",
- code=OrderErrorCode.QUANTITY_LESS_THAN_ONE,
+ "Ensure this value is greater than 0.",
+ code=OrderErrorCode.ZERO_QUANTITY,
)
}
)
@@ -406,8 +406,8 @@ class DraftOrderLineUpdate(ModelMutation):
raise ValidationError(
{
"quantity": ValidationError(
- "Ensure this value is greater than or equal to 1.",
- code=OrderErrorCode.QUANTITY_LESS_THAN_ONE,
+ "Ensure this value is greater than 0.",
+ code=OrderErrorCode.ZERO_QUANTITY,
)
}
)
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index c306bb5396..20a9bb792e 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -70,7 +70,7 @@ def clean_payment(payment):
{
"payment": ValidationError(
"There's no payment associated with the order.",
- code=OrderErrorCode.ORDER_NO_PAYMENT,
+ code=OrderErrorCode.PAYMENT_MISSING,
)
}
)
@@ -110,7 +110,7 @@ def clean_refund_payment(payment):
{
"payment": ValidationError(
"Manual payments can not be refunded.",
- code=OrderErrorCode.REFUND_MANUAL_PAYMENT,
+ code=OrderErrorCode.CANNOT_REFUND,
)
}
)
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 8f39150567..b7a2858329 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1399,14 +1399,14 @@ enum ErrorCode {
CANNOT_ASSIGN_NODE
CANNOT_CANCEL_FULFILLMENT
CANNOT_CANCEL_ORDER
+ CANNOT_DELETE
CANNOT_FETCH_TAX_RATES
+ CANNOT_REFUND
CAPTURE_INACTIVE_PAYMENT
CHECKOUT_NOT_FULLY_PAID
CONTRADICTION
DEACTIVATE_OWN_ACCOUNT
DEACTIVATE_SUPERUSER_ACCOUNT
- DELETE_LINE_NON_DRAFT_ORDER
- DELETE_NON_DRAFT_ORDER
DELETE_NON_STAFF_USER
DELETE_OWN_ACCOUNT
DELETE_STAFF_ACCOUNT
@@ -1456,7 +1456,6 @@ enum ErrorCode {
OBJECT_ALREADY_EXISTS
OBJECT_DOES_NOT_EXIST
ORDER_INVALID_SHIPPING_METHOD
- ORDER_NO_PAYMENT
ORDER_NO_SHIPPING_ADDRESS
ORDER_WITHOUT_PRODUCTS
OVERFLOW
@@ -1466,10 +1465,10 @@ enum ErrorCode {
PASSWORD_TOO_SHORT
PASSWORD_TOO_SIMILAR
PAYMENT_ERROR
+ PAYMENT_MISSING
+ PLUGIN_MISCONFIGURED
POSITIVE_NUMBER_REQUIRED
QUANTITY_GREATER_THAN_LIMIT
- QUANTITY_LESS_THAN_ONE
- REFUND_MANUAL_PAYMENT
REQUIRED
SHIPPING_ADDRESS_NOT_SET
SHIPPING_METHOD_NOT_APPLICABLE
@@ -1484,6 +1483,7 @@ enum ErrorCode {
VARIANT_NO_DIGITAL_CONTENT
VOID_INACTIVE_PAYMENT
VOUCHER_NOT_APPLICABLE
+ ZERO_QUANTITY
}
type Fulfillment implements Node {