Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions orders/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class AbstractPurchaseException(Exception):
def __init__(self, msg, type):
self.msg = msg
self.type = type

self.log()
super().__init__(msg)

def __str__(self):
return self.msg

def log(self):
print(f"[EXCEPTION] {self.msg}")


class StockLackException(AbstractPurchaseException):
"""결제오류(재고부족)"""

def __init__(self, product):
super().__init__(f"{product.title}의 재고가 부족합니다", "error_stock")


class PriceMatchException(AbstractPurchaseException):
"""결제오류(총가격 불일치)"""

def __init__(self):
super().__init__("클라이언트 요청 금액과 DB에 저장된 금액이 일치하지 않습니다.", "error_price_match")


class ServerErrorException(AbstractPurchaseException):
"""결제오류(서버)"""

def __init__(self):
super().__init__("서버에 오류가 있었습니다. 다시 시도해주세요", "error_server")


class ValidErrorException(AbstractPurchaseException):
"""결제오류(검증)"""

def __init__(self):
super().__init__("결제 검증에 오류가 있습니다. 다시 시도해주세요", "error_valid")