-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
delivery/src/main/java/delivery/common/error/GoodsErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum GoodsErrorCode implements ErrorCodeIfs { | ||
|
||
GOODS_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1200, "물품이 존재하지 않습니다."), | ||
INVALID_GOODS_STATUS(HttpStatus.BAD_REQUEST.value(),1201,"잘못된 물품 상태입니다."), | ||
INVALID_GOODS_STRATEGY(HttpStatus.BAD_REQUEST.value(), 1202, "요청서 종류가 잘못되었습니다."), | ||
NOT_OWNER(HttpStatus.NOT_ACCEPTABLE.value(), 1203, "소유자가 아닙니다.") | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
delivery/src/main/java/delivery/common/error/ImageErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ImageErrorCode implements ErrorCodeIfs { | ||
|
||
IMAGE_STORAGE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR.value(), 1300, "이미지를 저장할 수 없습니다."), | ||
NULL_POINT(HttpStatus.INTERNAL_SERVER_ERROR.value(), 1301, "NULL POINT 입니다."), | ||
IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1302, "요청하신 이미지를 찾을 수 없습니다."), | ||
IMAGE_STORAGE_PATH_ERROR(HttpStatus.INTERNAL_SERVER_ERROR.value(), 1303, "업로드된 파일이 저장될 디렉터리를 생성할 수 없습니다.") | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ReceivingErrorCode implements ErrorCodeIfs { | ||
|
||
RECEIVING_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1250, "입고 요청서가 존재하지 않습니다."), | ||
NO_OWNERSHIP(HttpStatus.BAD_REQUEST.value(), 1251, "사용자의 물품이 아닙니다.") | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
} |
18 changes: 18 additions & 0 deletions
18
delivery/src/main/java/delivery/common/error/ShippingErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ShippingErrorCode implements ErrorCodeIfs { | ||
|
||
SHIPPING_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1500, "출고 요청서가 존재하지 않습니다.") | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
} |
20 changes: 20 additions & 0 deletions
20
delivery/src/main/java/delivery/common/error/TakeBackErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum TakeBackErrorCode implements ErrorCodeIfs { | ||
|
||
TAKE_BAKE_NOT_ALLOWED(HttpStatus.BAD_REQUEST.value(), 1400, "반품을 진행할 수 없습니다."), | ||
NOT_FOUNT_REQUEST(HttpStatus.BAD_REQUEST.value(), 1401, "반품 요청서를 찾을 수 없습니다.") | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
delivery/src/main/java/delivery/common/error/TokenErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum TokenErrorCode implements ErrorCodeIfs { | ||
|
||
NOT_AUTHENTICATION_USER(401,1100,"로그인이 필요합니다."), | ||
NOT_AUTHORIZATION_USER(404,1101,"허가된 접근이 아닙니다."), | ||
INVALID_TOKEN(401,1102,"유효하지 않은 토큰입니다."), | ||
EXPIRED_TOKEN(401,1103,"만료된 토큰입니다."), | ||
TOKEN_EXCEPTION(401,1104,"알 수 없는 토큰 에러입니다."), | ||
NON_TOKEN_HEADER(401,1105,"인증 헤더 토큰이 없습니다."), | ||
NO_EXPIRED_TOKEN(400,1106,"만료되지 않은 토큰입니다."), | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
delivery/src/main/java/delivery/common/error/UsedGoodsErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum UsedGoodsErrorCode implements ErrorCodeIfs { | ||
|
||
USED_GOODS_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1600, "중고 물품을 찾을 수 없습니다."), | ||
GOODS_NOT_IN_USED_STATUS(HttpStatus.BAD_REQUEST.value(), 1601, "물품이 중고 전환 상태가 아닙니다."); | ||
; | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
delivery/src/main/java/delivery/common/error/UserErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package delivery.common.error; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum UserErrorCode implements ErrorCodeIfs { | ||
|
||
FAILED_TO_REGISTER(500, 1150, "회원가입이 실패했습니다."), | ||
USER_NOT_FOUND(404, 1151, "사용자를 찾을 수 없습니다."), | ||
UNREGISTERED_MEMBER(403, 1152, "탈퇴한 회원입니다."), | ||
DORMANT_MEMBER(403, 1153, "휴면 계정입니다."), | ||
EXIST_USER(403, 1154, "이미 존재하는 아이디입니다."), | ||
LOGIN_FAIL(401, 1155, "로그인 정보가 일치하지 않습니다."), | ||
ADDRESS_NOT_FOUND(404, 1156, "사용자의 주소를 찾을 수 없습니다."), | ||
FAILED_TO_UNREGISTER(500, 1157, "회원 탈퇴에 실패했습니다."); | ||
|
||
private final Integer httpCode; | ||
private final Integer errorCode; | ||
private final String description; | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
delivery/src/main/java/delivery/common/exception/ApiException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package delivery.common.exception; | ||
|
||
import global.errorcode.ErrorCodeIfs; | ||
|
||
public class ApiException extends RuntimeException{ | ||
|
||
private final ErrorCodeIfs errorCodeIfs; | ||
private final String description; | ||
|
||
public ApiException(ErrorCodeIfs errorCodeIfs) { | ||
super(errorCodeIfs.getDescription()); | ||
this.errorCodeIfs = errorCodeIfs; | ||
this.description = errorCodeIfs.getDescription(); | ||
} | ||
|
||
public ApiException(ErrorCodeIfs errorCodeIfs, String errorDescription) { | ||
this.errorCodeIfs = errorCodeIfs; | ||
this.description = errorDescription; | ||
} | ||
|
||
public ApiException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { | ||
super(throwable); | ||
this.errorCodeIfs = errorCodeIfs; | ||
this.description = errorCodeIfs.getDescription(); | ||
} | ||
|
||
public ApiException(ErrorCodeIfs errorCodeIfs, Throwable throwable, | ||
String errorDescription) { | ||
super(throwable); | ||
this.errorCodeIfs = errorCodeIfs; | ||
this.description = errorDescription; | ||
} | ||
|
||
|
||
} |
40 changes: 40 additions & 0 deletions
40
delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package delivery.common.exception; | ||
|
||
import delivery.common.error.GoodsErrorCode; | ||
import delivery.common.exception.goods.GoodsNotFoundException; | ||
import delivery.common.exception.goods.InvalidGoodsStatusException; | ||
import delivery.common.exception.receiving.NotOwnerException; | ||
import global.api.Api; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
@Order(value = Integer.MIN_VALUE) | ||
public class GoodsExceptionHandler { | ||
|
||
@ExceptionHandler(value = GoodsNotFoundException.class) | ||
public ResponseEntity<Api<Object>> imageException(GoodsNotFoundException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND) | ||
.body(Api.ERROR(GoodsErrorCode.GOODS_NOT_FOUND)); | ||
} | ||
|
||
@ExceptionHandler(value = InvalidGoodsStatusException.class) | ||
public ResponseEntity<Api<Object>> InvalidGoodsStatus(InvalidGoodsStatusException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(Api.ERROR(GoodsErrorCode.INVALID_GOODS_STATUS)); | ||
} | ||
|
||
@ExceptionHandler(value = NotOwnerException.class) | ||
public ResponseEntity<Api<Object>> notOwnerException(NotOwnerException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(Api.ERROR(GoodsErrorCode.NOT_OWNER)); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package delivery.common.exception; | ||
|
||
import delivery.common.error.ReceivingErrorCode; | ||
import delivery.common.exception.receiving.NoOwnershipException; | ||
import delivery.common.exception.receiving.ReceivingNotFoundException; | ||
import global.api.Api; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
@Order(value = Integer.MIN_VALUE) | ||
public class ReceivingExceptionHandler { | ||
|
||
@ExceptionHandler(value = ReceivingNotFoundException.class) | ||
public ResponseEntity<Api<Object>> imageException(ReceivingNotFoundException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND) | ||
.body(Api.ERROR(ReceivingErrorCode.RECEIVING_REQUEST_NOT_FOUND)); | ||
} | ||
|
||
@ExceptionHandler(value = NoOwnershipException.class) | ||
public ResponseEntity<Api<Object>> noOwnershipException(NoOwnershipException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(Api.ERROR(ReceivingErrorCode.NO_OWNERSHIP)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package delivery.common.exception; | ||
|
||
import delivery.common.error.ShippingErrorCode; | ||
import delivery.common.exception.shipping.ShippingNotFoundException; | ||
import global.api.Api; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class ShippingExceptionHandler { | ||
|
||
@ExceptionHandler(value = ShippingNotFoundException.class) | ||
public ResponseEntity<Api<Object>> shippingNotFoundException(ShippingNotFoundException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND) | ||
.body(Api.ERROR(ShippingErrorCode.SHIPPING_REQUEST_NOT_FOUND)); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
delivery/src/main/java/delivery/common/exception/TakeBackExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package delivery.common.exception; | ||
|
||
import delivery.common.error.TakeBackErrorCode; | ||
import delivery.common.exception.takeback.NotFoundRequestException; | ||
import delivery.common.exception.takeback.TakeBackNotAllowedException; | ||
import global.api.Api; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class TakeBackExceptionHandler { | ||
|
||
@ExceptionHandler(value = TakeBackNotAllowedException.class) | ||
public ResponseEntity<Api<Object>> takeBakeException(TakeBackNotAllowedException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(Api.ERROR(TakeBackErrorCode.TAKE_BAKE_NOT_ALLOWED)); | ||
} | ||
|
||
@ExceptionHandler(value = NotFoundRequestException.class) | ||
public ResponseEntity<Api<Object>> notFoundRequestException(NotFoundRequestException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(Api.ERROR(TakeBackErrorCode.NOT_FOUNT_REQUEST)); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
delivery/src/main/java/delivery/common/exception/UsedGoodsExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package delivery.common.exception; | ||
|
||
import delivery.common.error.UsedGoodsErrorCode; | ||
import delivery.common.exception.usedGoods.GoodsNotInUsedStatus; | ||
import delivery.common.exception.usedGoods.UsedGoodsNotFoundException; | ||
import global.api.Api; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class UsedGoodsExceptionHandler { | ||
|
||
@ExceptionHandler(value = UsedGoodsNotFoundException.class) | ||
public ResponseEntity<Api<Object>> usedGoodsNotFoundException(UsedGoodsNotFoundException e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND) | ||
.body(Api.ERROR(UsedGoodsErrorCode.USED_GOODS_NOT_FOUND)); | ||
} | ||
|
||
@ExceptionHandler(value = GoodsNotInUsedStatus.class) | ||
public ResponseEntity<Api<Object>> goodsNotInUsedStatus(GoodsNotInUsedStatus e) { | ||
log.info("", e); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(Api.ERROR(UsedGoodsErrorCode.GOODS_NOT_IN_USED_STATUS)); | ||
} | ||
|
||
} |
Oops, something went wrong.