Skip to content

Commit 8a290af

Browse files
committed
Repackaged errors and responses for the core.
1 parent ba584a4 commit 8a290af

File tree

11 files changed

+38
-38
lines changed

11 files changed

+38
-38
lines changed

core/core-api/src/main/java/io/dodn/springboot/core/api/config/AsyncExceptionHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.dodn.springboot.core.api.config;
22

3-
import io.dodn.springboot.core.api.support.error.CoreApiException;
3+
import io.dodn.springboot.core.support.error.CoreException;
44

55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
@@ -14,11 +14,11 @@ public class AsyncExceptionHandler implements AsyncUncaughtExceptionHandler {
1414

1515
@Override
1616
public void handleUncaughtException(Throwable e, Method method, Object... params) {
17-
if (e instanceof CoreApiException) {
18-
switch (((CoreApiException) e).getErrorType().getLogLevel()) {
19-
case ERROR -> log.error("CoreApiException : {}", e.getMessage(), e);
20-
case WARN -> log.warn("CoreApiException : {}", e.getMessage(), e);
21-
default -> log.info("CoreApiException : {}", e.getMessage(), e);
17+
if (e instanceof CoreException) {
18+
switch (((CoreException) e).getErrorType().getLogLevel()) {
19+
case ERROR -> log.error("CoreException : {}", e.getMessage(), e);
20+
case WARN -> log.warn("CoreException : {}", e.getMessage(), e);
21+
default -> log.info("CoreException : {}", e.getMessage(), e);
2222
}
2323
}
2424
else {

core/core-api/src/main/java/io/dodn/springboot/core/api/controller/ApiControllerAdvice.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.dodn.springboot.core.api.controller;
22

3-
import io.dodn.springboot.core.api.support.error.CoreApiException;
4-
import io.dodn.springboot.core.api.support.error.ErrorType;
5-
import io.dodn.springboot.core.api.support.response.ApiResponse;
3+
import io.dodn.springboot.core.support.error.CoreException;
4+
import io.dodn.springboot.core.support.error.ErrorType;
5+
import io.dodn.springboot.core.support.response.ApiResponse;
66

77
import org.slf4j.Logger;
88
import org.slf4j.LoggerFactory;
@@ -15,12 +15,12 @@ public class ApiControllerAdvice {
1515

1616
private final Logger log = LoggerFactory.getLogger(getClass());
1717

18-
@ExceptionHandler(CoreApiException.class)
19-
public ResponseEntity<ApiResponse<?>> handleCoreApiException(CoreApiException e) {
18+
@ExceptionHandler(CoreException.class)
19+
public ResponseEntity<ApiResponse<?>> handleCoreException(CoreException e) {
2020
switch (e.getErrorType().getLogLevel()) {
21-
case ERROR -> log.error("CoreApiException : {}", e.getMessage(), e);
22-
case WARN -> log.warn("CoreApiException : {}", e.getMessage(), e);
23-
default -> log.info("CoreApiException : {}", e.getMessage(), e);
21+
case ERROR -> log.error("CoreException : {}", e.getMessage(), e);
22+
case WARN -> log.warn("CoreException : {}", e.getMessage(), e);
23+
default -> log.info("CoreException : {}", e.getMessage(), e);
2424
}
2525
return new ResponseEntity<>(ApiResponse.error(e.getErrorType(), e.getData()), e.getErrorType().getStatus());
2626
}

core/core-api/src/main/java/io/dodn/springboot/core/api/controller/v1/ExampleController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.dodn.springboot.core.domain.ExampleData;
66
import io.dodn.springboot.core.domain.ExampleResult;
77
import io.dodn.springboot.core.domain.ExampleService;
8-
import io.dodn.springboot.core.api.support.response.ApiResponse;
8+
import io.dodn.springboot.core.support.response.ApiResponse;
99

1010
import org.springframework.web.bind.annotation.GetMapping;
1111
import org.springframework.web.bind.annotation.PathVariable;

core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorCode.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ResultType.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/CoreApiException.java renamed to core/core-api/src/main/java/io/dodn/springboot/core/support/error/CoreException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
package io.dodn.springboot.core.api.support.error;
1+
package io.dodn.springboot.core.support.error;
22

3-
public class CoreApiException extends RuntimeException {
3+
public class CoreException extends RuntimeException {
44

55
private final ErrorType errorType;
66

77
private final Object data;
88

9-
public CoreApiException(ErrorType errorType) {
9+
public CoreException(ErrorType errorType) {
1010
super(errorType.getMessage());
1111
this.errorType = errorType;
1212
this.data = null;
1313
}
1414

15-
public CoreApiException(ErrorType errorType, Object data) {
15+
public CoreException(ErrorType errorType, Object data) {
1616
super(errorType.getMessage());
1717
this.errorType = errorType;
1818
this.data = data;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.dodn.springboot.core.support.error;
2+
3+
public enum ErrorCode {
4+
5+
E500
6+
7+
}

core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorMessage.java renamed to core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.dodn.springboot.core.api.support.error;
1+
package io.dodn.springboot.core.support.error;
22

33
public class ErrorMessage {
44

core/core-api/src/main/java/io/dodn/springboot/core/api/support/error/ErrorType.java renamed to core/core-api/src/main/java/io/dodn/springboot/core/support/error/ErrorType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.dodn.springboot.core.api.support.error;
1+
package io.dodn.springboot.core.support.error;
22

33
import org.springframework.boot.logging.LogLevel;
44
import org.springframework.http.HttpStatus;

core/core-api/src/main/java/io/dodn/springboot/core/api/support/response/ApiResponse.java renamed to core/core-api/src/main/java/io/dodn/springboot/core/support/response/ApiResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package io.dodn.springboot.core.api.support.response;
1+
package io.dodn.springboot.core.support.response;
22

3-
import io.dodn.springboot.core.api.support.error.ErrorMessage;
4-
import io.dodn.springboot.core.api.support.error.ErrorType;
3+
import io.dodn.springboot.core.support.error.ErrorMessage;
4+
import io.dodn.springboot.core.support.error.ErrorType;
55

66
public class ApiResponse<S> {
77

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.dodn.springboot.core.support.response;
2+
3+
public enum ResultType {
4+
5+
SUCCESS, ERROR
6+
7+
}

0 commit comments

Comments
 (0)