Skip to content

Commit 9013720

Browse files
committed
mod::generalexception으로 에러처리
1 parent c257487 commit 9013720

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ontime-back/src/main/java/devkor/ontime_back/LoggingAspect.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,11 @@ private ApiLog buildApiLog(RequestInfoDto info, int responseStatus, long timeTak
149149
.build();
150150
}
151151

152-
// Exception 매핑
153-
private static final Map<Class<? extends Exception>, Integer> EXCEPTION_STATUS_MAP = Map.of(
154-
IllegalArgumentException.class, 400,
155-
AccessDeniedException.class, 403,
156-
MethodArgumentNotValidException.class, 422
157-
);
158-
159152
private int mapExceptionToStatusCode(Exception e) {
160-
return EXCEPTION_STATUS_MAP.getOrDefault(e.getClass(), 500);
153+
if (e instanceof GeneralException ge) {
154+
return ge.getErrorCode().getCode();
155+
}
156+
return 500;
161157
}
162158

163159
}

0 commit comments

Comments
 (0)