diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/BizException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/BizException.java deleted file mode 100644 index aebb696b..00000000 --- a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/BizException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.bancow.bancowback.domain.common.exception; - -public class BizException extends RuntimeException { - public BizException(String message) { - super(message); - } -} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ErrorCode.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ErrorCode.java index a3da8378..3e59a008 100644 --- a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ErrorCode.java +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ErrorCode.java @@ -45,6 +45,21 @@ public enum ErrorCode { // NEWS NOT_FOUND_NEWS("N001", "Not Found News"), + + // TOKEN + NOT_FOUND_TOKEN("TK001", "Not Found Token"), + NOT_AUTHORITY("TK002", "Not Authority Token"), + NOT_AUTHORITY_SUPER("TK003", "Not Super Token"), + + // MANGER + NOT_FOUND_MANAGER("M001", "NOT FOUND MANAGER"), + NOT_VALID_PASSWORD("M002", "NOT VALID PASSWORD"), + NOT_VALID_USER("M003", "NOT VALID USER"), + + // REGISTER + DUPLICATE_EMAIL("R001", "Duplicate Email"), + NOT_EQUAL_PASSWORD("R002", "Password 1, 2 Not Equal"), + ; private final String code; private final String message; diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/GlobalExceptionHandler.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/GlobalExceptionHandler.java index 12167e94..fb0b34f6 100644 --- a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/GlobalExceptionHandler.java +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/GlobalExceptionHandler.java @@ -9,8 +9,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; -import com.bancow.bancowback.domain.sub.news.entity.News; - import lombok.extern.slf4j.Slf4j; @ControllerAdvice @@ -122,5 +120,62 @@ protected ResponseEntity handlerNewsException(NewsException e) { final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_FOUND_NEWS); return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); } + + @ExceptionHandler(TokenAuthorityException.class) + protected ResponseEntity handlerTokenAuthorityException(TokenAuthorityException e) { + log.error("TokenAuthorityException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_AUTHORITY); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(TokenAuthoritySuperException.class) + protected ResponseEntity handlerTokenAuthoritySuperException(TokenAuthoritySuperException e) { + log.error("TokenAuthoritySuperException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_AUTHORITY_SUPER); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(TokenNotFoundException.class) + protected ResponseEntity handlerTokenException(TokenNotFoundException e) { + log.error("TokenNotFoundException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_FOUND_TOKEN); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(ManagerNotFoundException.class) + protected ResponseEntity handlerManagerNotFoundException(ManagerNotFoundException e) { + log.error("ManagerNotFoundException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_FOUND_MANAGER); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(ManagerNotValidPasswordException.class) + protected ResponseEntity handlerManagerNotValidPasswordException(ManagerNotValidPasswordException e) { + log.error("ManagerNotValidPasswordException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_VALID_PASSWORD); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(ManagerNotValidException.class) + protected ResponseEntity handlerManagerNotValidException(ManagerNotValidException e) { + log.error("ManagerNotValidException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_VALID_USER); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(RegisterDuplicateEmailException.class) + protected ResponseEntity handlerRegisterDuplicateEmailException(RegisterDuplicateEmailException e) { + log.error("RegisterDuplicateEmailException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.DUPLICATE_EMAIL); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(RegisterNotEqualPasswordException.class) + protected ResponseEntity handlerRegisterNotEqualPasswordException( + RegisterNotEqualPasswordException e) { + log.error("RegisterNotEqualPasswordException", e); + final ErrorResponse response = ErrorResponse.of(ErrorCode.NOT_EQUAL_PASSWORD); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } } diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotFoundException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotFoundException.java new file mode 100644 index 00000000..745596b3 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotFoundException.java @@ -0,0 +1,16 @@ +package com.bancow.bancowback.domain.common.exception; + +import lombok.Getter; + +@Getter +public class ManagerNotFoundException extends RuntimeException { + private ErrorCode managerErrorCode; + private String detailMessage; + + public ManagerNotFoundException(ErrorCode managerErrorCode, String detailMessage) { + super(detailMessage); + this.managerErrorCode = managerErrorCode; + this.detailMessage = detailMessage; + } + +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotValidException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotValidException.java new file mode 100644 index 00000000..15e370f0 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotValidException.java @@ -0,0 +1,16 @@ +package com.bancow.bancowback.domain.common.exception; + +import lombok.Getter; + +@Getter +public class ManagerNotValidException extends RuntimeException { + private ErrorCode managerErrorCode; + private String detailMessage; + + public ManagerNotValidException(ErrorCode managerErrorCode, String detailMessage) { + super(detailMessage); + this.managerErrorCode = managerErrorCode; + this.detailMessage = detailMessage; + } + +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotValidPasswordException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotValidPasswordException.java new file mode 100644 index 00000000..d765c590 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/ManagerNotValidPasswordException.java @@ -0,0 +1,16 @@ +package com.bancow.bancowback.domain.common.exception; + +import lombok.Getter; + +@Getter +public class ManagerNotValidPasswordException extends RuntimeException { + private ErrorCode managerErrorCode; + private String detailMessage; + + public ManagerNotValidPasswordException(ErrorCode managerErrorCode, String detailMessage) { + super(detailMessage); + this.managerErrorCode = managerErrorCode; + this.detailMessage = detailMessage; + } + +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/RegisterDuplicateEmailException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/RegisterDuplicateEmailException.java new file mode 100644 index 00000000..9cc305f1 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/RegisterDuplicateEmailException.java @@ -0,0 +1,16 @@ +package com.bancow.bancowback.domain.common.exception; + +import lombok.Getter; + +@Getter +public class RegisterDuplicateEmailException extends RuntimeException { + private ErrorCode registerErrorCode; + private String detailMessage; + + public RegisterDuplicateEmailException(ErrorCode registerErrorCode, String detailMessage) { + super(detailMessage); + this.registerErrorCode = registerErrorCode; + this.detailMessage = detailMessage; + } + +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/RegisterNotEqualPasswordException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/RegisterNotEqualPasswordException.java new file mode 100644 index 00000000..8793bda4 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/RegisterNotEqualPasswordException.java @@ -0,0 +1,16 @@ +package com.bancow.bancowback.domain.common.exception; + +import lombok.Getter; + +@Getter +public class RegisterNotEqualPasswordException extends RuntimeException { + private ErrorCode registerErrorCode; + private String detailMessage; + + public RegisterNotEqualPasswordException(ErrorCode registerErrorCode, String detailMessage) { + super(detailMessage); + this.registerErrorCode = registerErrorCode; + this.detailMessage = detailMessage; + } + +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenAuthorityException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenAuthorityException.java new file mode 100644 index 00000000..486927c1 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenAuthorityException.java @@ -0,0 +1,8 @@ +package com.bancow.bancowback.domain.common.exception; + +public class TokenAuthorityException extends TokenNotFoundException { + + public TokenAuthorityException(ErrorCode tokenErrorCode, String detailMessage) { + super(tokenErrorCode, detailMessage); + } +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenAuthoritySuperException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenAuthoritySuperException.java new file mode 100644 index 00000000..69e658c8 --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenAuthoritySuperException.java @@ -0,0 +1,8 @@ +package com.bancow.bancowback.domain.common.exception; + +public class TokenAuthoritySuperException extends TokenNotFoundException { + + public TokenAuthoritySuperException(ErrorCode tokenErrorCode, String detailMessage) { + super(tokenErrorCode, detailMessage); + } +} diff --git a/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenNotFoundException.java b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenNotFoundException.java new file mode 100644 index 00000000..11f5884d --- /dev/null +++ b/spring/src/main/java/com/bancow/bancowback/domain/common/exception/TokenNotFoundException.java @@ -0,0 +1,16 @@ +package com.bancow.bancowback.domain.common.exception; + +import lombok.Getter; + +@Getter +public class TokenNotFoundException extends RuntimeException { + private ErrorCode tokenErrorCode; + private String detailMessage; + + public TokenNotFoundException(ErrorCode tokenErrorCode, String detailMessage) { + super(detailMessage); + this.tokenErrorCode = tokenErrorCode; + this.detailMessage = detailMessage; + } + +}