Skip to content

Commit

Permalink
Merge pull request #313 from ASAP-as-soon-as-possible/feat/#265
Browse files Browse the repository at this point in the history
#265 [feat] IllegalArgumentException 에러 수집
  • Loading branch information
KWY0218 authored Aug 17, 2024
2 parents fdff40c + ce3a6e6 commit 6d4f340
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/asap/server/common/exception/Error.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum Error {
**/
INVALID_MEETING_URL_EXCEPTION(HttpStatus.BAD_REQUEST, "유효하지 않는 URL 입니다."),
VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "요청값이 유효하지 않습니다."),
ILLEGAL_ARGUMENT_EXCEPTION(HttpStatus.BAD_REQUEST, "유효하지 않은 값이 입력되었습니다."),
DUPLICATED_DATE_EXCEPTION(HttpStatus.BAD_REQUEST, "중복 입력된 날짜가 있습니다."),
DUPLICATED_TIME_EXCEPTION(HttpStatus.BAD_REQUEST, "중복 입력된 시간이 있습니다."),
INVALID_TIME_RANGE(HttpStatus.BAD_REQUEST, "입력한 시간이 회의 가능 일시에 해당하지 않습니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.asap.server.presentation.common.advice;

import com.asap.server.presentation.common.dto.ErrorDataResponse;
import com.asap.server.presentation.common.dto.ErrorResponse;
import com.asap.server.infra.slack.SlackUtil;
import com.asap.server.presentation.controller.dto.response.HostLoginResponseDto;
import static com.asap.server.common.exception.Error.METHOD_NOT_ALLOWED_EXCEPTION;

import com.asap.server.common.exception.Error;
import com.asap.server.common.exception.model.AsapException;
import com.asap.server.common.exception.model.BadRequestException;
Expand All @@ -14,9 +12,15 @@
import com.asap.server.common.exception.model.NotFoundException;
import com.asap.server.common.exception.model.TooManyRequestException;
import com.asap.server.common.exception.model.UnauthorizedException;
import com.asap.server.infra.slack.SlackUtil;
import com.asap.server.presentation.common.dto.ErrorDataResponse;
import com.asap.server.presentation.common.dto.ErrorResponse;
import com.asap.server.presentation.controller.dto.response.HostLoginResponseDto;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.ConstraintViolationException;
import jakarta.validation.ValidationException;
import java.io.IOException;
import java.time.DateTimeException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand All @@ -29,11 +33,6 @@
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;

import java.io.IOException;
import java.time.DateTimeException;

import static com.asap.server.common.exception.Error.METHOD_NOT_ALLOWED_EXCEPTION;

@Slf4j
@RestControllerAdvice
@RequiredArgsConstructor
Expand All @@ -50,6 +49,12 @@ protected ErrorResponse handleValidException(final ValidationException e) {
return ErrorResponse.error(Error.VALIDATION_REQUEST_MISSING_EXCEPTION);
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(IllegalArgumentException.class)
protected ErrorResponse handleIllegalArgumentException(final IllegalArgumentException e) {
return ErrorResponse.error(Error.ILLEGAL_ARGUMENT_EXCEPTION);
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(DateTimeException.class)
protected ErrorResponse handleDateTimeException(final DateTimeException e) {
Expand Down

0 comments on commit 6d4f340

Please sign in to comment.