diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/config/AsyncExceptionHandler.java b/core/core-api/src/main/java/io/dodn/springboot/core/api/config/AsyncExceptionHandler.java index 0ac2863..8697ca4 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/config/AsyncExceptionHandler.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/api/config/AsyncExceptionHandler.java @@ -1,6 +1,6 @@ package io.dodn.springboot.core.api.config; -import io.dodn.springboot.core.api.support.error.CoreApiException; +import io.dodn.springboot.core.support.error.CoreException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,11 +14,11 @@ public class AsyncExceptionHandler implements AsyncUncaughtExceptionHandler { @Override public void handleUncaughtException(Throwable e, Method method, Object... params) { - if (e instanceof CoreApiException) { - switch (((CoreApiException) e).getErrorType().getLogLevel()) { - case ERROR -> log.error("CoreApiException : {}", e.getMessage(), e); - case WARN -> log.warn("CoreApiException : {}", e.getMessage(), e); - default -> log.info("CoreApiException : {}", e.getMessage(), e); + if (e instanceof CoreException) { + switch (((CoreException) e).getErrorType().getLogLevel()) { + case ERROR -> log.error("CoreException : {}", e.getMessage(), e); + case WARN -> log.warn("CoreException : {}", e.getMessage(), e); + default -> log.info("CoreException : {}", e.getMessage(), e); } } else { diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/ApiControllerAdvice.java b/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/ApiControllerAdvice.java index e8cc2f8..6f73e54 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/ApiControllerAdvice.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/ApiControllerAdvice.java @@ -1,8 +1,8 @@ package io.dodn.springboot.core.api.controller; -import io.dodn.springboot.core.api.support.error.CoreApiException; -import io.dodn.springboot.core.api.support.error.ErrorType; -import io.dodn.springboot.core.api.support.response.ApiResponse; +import io.dodn.springboot.core.support.error.CoreException; +import io.dodn.springboot.core.support.error.ErrorType; +import io.dodn.springboot.core.support.response.ApiResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,12 +15,12 @@ public class ApiControllerAdvice { private final Logger log = LoggerFactory.getLogger(getClass()); - @ExceptionHandler(CoreApiException.class) - public ResponseEntity> handleCoreApiException(CoreApiException e) { + @ExceptionHandler(CoreException.class) + public ResponseEntity> handleCoreException(CoreException e) { switch (e.getErrorType().getLogLevel()) { - case ERROR -> log.error("CoreApiException : {}", e.getMessage(), e); - case WARN -> log.warn("CoreApiException : {}", e.getMessage(), e); - default -> log.info("CoreApiException : {}", e.getMessage(), e); + case ERROR -> log.error("CoreException : {}", e.getMessage(), e); + case WARN -> log.warn("CoreException : {}", e.getMessage(), e); + default -> log.info("CoreException : {}", e.getMessage(), e); } return new ResponseEntity<>(ApiResponse.error(e.getErrorType(), e.getData()), e.getErrorType().getStatus()); } diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/v1/ExampleController.java b/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/v1/ExampleController.java index 453240f..8391b97 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/v1/ExampleController.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/api/controller/v1/ExampleController.java @@ -5,7 +5,7 @@ import io.dodn.springboot.core.domain.ExampleData; import io.dodn.springboot.core.domain.ExampleResult; import io.dodn.springboot.core.domain.ExampleService; -import io.dodn.springboot.core.api.support.response.ApiResponse; +import io.dodn.springboot.core.support.response.ApiResponse; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorCode.java b/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorCode.java deleted file mode 100644 index f42c97d..0000000 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorCode.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.dodn.springboot.core.api.support.error; - -public enum ErrorCode { - - E500 - -} diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ResultType.java b/core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ResultType.java deleted file mode 100644 index c45bd83..0000000 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ResultType.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.dodn.springboot.core.api.support.response; - -public enum ResultType { - - SUCCESS, ERROR - -} diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/CoreApiException.java b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/CoreException.java similarity index 65% rename from core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/CoreApiException.java rename to core/core-api/src/main/java/io/dodn/springboot/core/support/error/CoreException.java index 109a334..edf2ed8 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/CoreApiException.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/CoreException.java @@ -1,18 +1,18 @@ -package io.dodn.springboot.core.api.support.error; +package io.dodn.springboot.core.support.error; -public class CoreApiException extends RuntimeException { +public class CoreException extends RuntimeException { private final ErrorType errorType; private final Object data; - public CoreApiException(ErrorType errorType) { + public CoreException(ErrorType errorType) { super(errorType.getMessage()); this.errorType = errorType; this.data = null; } - public CoreApiException(ErrorType errorType, Object data) { + public CoreException(ErrorType errorType, Object data) { super(errorType.getMessage()); this.errorType = errorType; this.data = data; diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorCode.java b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorCode.java new file mode 100644 index 0000000..2fe34d7 --- /dev/null +++ b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorCode.java @@ -0,0 +1,7 @@ +package io.dodn.springboot.core.support.error; + +public enum ErrorCode { + + E500 + +} diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorMessage.java b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorMessage.java similarity index 92% rename from core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorMessage.java rename to core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorMessage.java index d13c23f..feecfb0 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorMessage.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorMessage.java @@ -1,4 +1,4 @@ -package io.dodn.springboot.core.api.support.error; +package io.dodn.springboot.core.support.error; public class ErrorMessage { diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorType.java b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorType.java similarity index 94% rename from core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorType.java rename to core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorType.java index 00a0930..7ac4d9c 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorType.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorType.java @@ -1,4 +1,4 @@ -package io.dodn.springboot.core.api.support.error; +package io.dodn.springboot.core.support.error; import org.springframework.boot.logging.LogLevel; import org.springframework.http.HttpStatus; diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ApiResponse.java b/core/core-api/src/main/java/io/dodn/springboot/core/support/response/ApiResponse.java similarity index 85% rename from core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ApiResponse.java rename to core/core-api/src/main/java/io/dodn/springboot/core/support/response/ApiResponse.java index 864a107..a304c1f 100644 --- a/core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ApiResponse.java +++ b/core/core-api/src/main/java/io/dodn/springboot/core/support/response/ApiResponse.java @@ -1,7 +1,7 @@ -package io.dodn.springboot.core.api.support.response; +package io.dodn.springboot.core.support.response; -import io.dodn.springboot.core.api.support.error.ErrorMessage; -import io.dodn.springboot.core.api.support.error.ErrorType; +import io.dodn.springboot.core.support.error.ErrorMessage; +import io.dodn.springboot.core.support.error.ErrorType; public class ApiResponse { diff --git a/core/core-api/src/main/java/io/dodn/springboot/core/support/response/ResultType.java b/core/core-api/src/main/java/io/dodn/springboot/core/support/response/ResultType.java new file mode 100644 index 0000000..53cbb98 --- /dev/null +++ b/core/core-api/src/main/java/io/dodn/springboot/core/support/response/ResultType.java @@ -0,0 +1,7 @@ +package io.dodn.springboot.core.support.response; + +public enum ResultType { + + SUCCESS, ERROR + +}