From 5fb64dbc27c5ffc7b9bc09fc6cb3b742ac7e2587 Mon Sep 17 00:00:00 2001 From: Ogu1208 Date: Sun, 11 Aug 2024 09:19:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20product-BadRequest=20Exception=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20BadRequestEx?= =?UTF-8?q?ception=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/store/clothstar/common/error/ErrorCode.kt | 4 ++++ .../error/exception/order/BadRequestException.kt | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/main/kotlin/org/store/clothstar/common/error/exception/order/BadRequestException.kt diff --git a/src/main/kotlin/org/store/clothstar/common/error/ErrorCode.kt b/src/main/kotlin/org/store/clothstar/common/error/ErrorCode.kt index 7db0400..7998a21 100644 --- a/src/main/kotlin/org/store/clothstar/common/error/ErrorCode.kt +++ b/src/main/kotlin/org/store/clothstar/common/error/ErrorCode.kt @@ -27,6 +27,10 @@ enum class ErrorCode( OUT_OF_STOCK(HttpStatus.BAD_REQUEST, "품절된 상품입니다."), INSUFFICIENT_STOCK(HttpStatus.BAD_REQUEST, "주문 개수가 상품 재고보다 더 많아 요청을 처리할 수 없습니다."); + + // Product 관련 에러코드 + + fun ErrorCode(status: HttpStatus, message: String) { this.status = status this.message = message diff --git a/src/main/kotlin/org/store/clothstar/common/error/exception/order/BadRequestException.kt b/src/main/kotlin/org/store/clothstar/common/error/exception/order/BadRequestException.kt new file mode 100644 index 0000000..4d7aebe --- /dev/null +++ b/src/main/kotlin/org/store/clothstar/common/error/exception/order/BadRequestException.kt @@ -0,0 +1,14 @@ +package org.store.clothstar.common.error.exception.order + +import org.springframework.http.HttpStatus +import org.store.clothstar.common.error.ErrorCode + +class BadRequestException( + val code: ErrorCode +) : RuntimeException(code.message) { + val httpStatus: HttpStatus + get() = code.status + + val errorMessage: String + get() = code.message +} \ No newline at end of file