Skip to content

Commit

Permalink
[chore] loadMessage api 에러 로그 찍기
Browse files Browse the repository at this point in the history
  • Loading branch information
khee2 committed Jun 13, 2024
1 parent 9d803c3 commit 7ace487
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; // 로깅을 위해 추가
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.access.AccessDeniedException;
Expand Down Expand Up @@ -59,10 +60,16 @@ public void message(MessageDto messageDto) {
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content(mediaType = "application/json"))
})
@Parameter(name = "roomId", description = "메시지를 조회할 채팅방의 ID", required = true, example = "123")
public ResponseEntity<List<MessageDto>> loadMessage(
public ResponseEntity<?> loadMessage(
@RequestHeader(name = "ACCESS_TOKEN", required = false) String accessToken,
@RequestHeader(name = "REFRESH_TOKEN", required = false) String refreshToken,
@PathVariable String roomId) {
return ResponseEntity.ok(messageService.loadMessage(roomId));
try {
List<MessageDto> messages = messageService.loadMessage(roomId);
return ResponseEntity.ok(messages);
} catch (Exception e) {
log.error("Failed to load messages for room {}: {}", roomId, e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to load messages: " + e.getMessage());
}
}
}

0 comments on commit 7ace487

Please sign in to comment.