Skip to content

Commit

Permalink
Fix: running record 조회 api에서 잘못된 uri 매핑 수정 (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewon-pro authored Sep 26, 2024
1 parent 758f1fd commit d04a683
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import com.dnd.runus.global.exception.BaseException;
import com.dnd.runus.global.exception.type.ErrorType;
import com.dnd.runus.presentation.dto.response.ApiErrorDto;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.ConstraintViolationException;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
Expand All @@ -35,8 +37,13 @@ public ResponseEntity<ApiErrorDto> handleAuthException(AuthException e) {
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ApiErrorDto> handleException(Exception e) {
log.error("Unhandled exception: ", e);
public ResponseEntity<ApiErrorDto> handleException(Exception e, HttpServletRequest request) {
log.error(
"Unhandled exception[{}]: {}, method: {}, uri: {}",
e.getClass(),
e.getMessage(),
request.getMethod(),
request.getRequestURI());
return toResponseEntity(ErrorType.UNHANDLED_EXCEPTION, e.getMessage());
}

Expand All @@ -45,6 +52,12 @@ public ResponseEntity<ApiErrorDto> handleNoResourceFoundException(NoResourceFoun
return toResponseEntity(ErrorType.UNSUPPORTED_API, e.getMessage());
}

@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ResponseEntity<ApiErrorDto> handleHttpRequestMethodNotSupportedException(
HttpRequestMethodNotSupportedException e) {
return toResponseEntity(ErrorType.UNSUPPORTED_API, e.getMessage());
}

@ExceptionHandler(InsufficientAuthenticationException.class)
public ResponseEntity<ApiErrorDto> handleInsufficientAuthenticationException(
InsufficientAuthenticationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class RunningRecordController {
private final RunningRecordService runningRecordService;

@GetMapping("{runningRecordId}")
@GetMapping("/{runningRecordId}")
@Operation(summary = "러닝 기록 상세 조회", description = "RunngingRecord id로 러닝 상세 기록을 조회합니다.")
public RunningRecordQueryResponse getRunningRecord(@MemberId long memberId, @PathVariable long runningRecordId) {
return runningRecordService.getRunningRecord(memberId, runningRecordId);
Expand Down

0 comments on commit d04a683

Please sign in to comment.