Skip to content

Commit

Permalink
#50 feat: 선택 기능 예외처리 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
letskuku committed Jul 30, 2023
1 parent a13e165 commit bfe7194
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.cherrypickserver.chat.exception;

public class ChatSelectNotFoundException extends RuntimeException {
public ChatSelectNotFoundException() {
super("선택 요청에 대한 답변을 찾을 수 없습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.cherrypickserver.chat.exception;

public class SelectTypeNotFoundException extends RuntimeException {
public SelectTypeNotFoundException() {
super("해당하는 Select Type을 찾을 수 없습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.cherrypickserver.chat.presentation;

import com.example.cherrypickserver.chat.exception.ChatSelectNotFoundException;
import com.example.cherrypickserver.chat.exception.SelectTypeNotFoundException;
import com.example.cherrypickserver.global.dto.ResponseCustom;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class ChatExceptionController {

@ExceptionHandler(ChatSelectNotFoundException.class)
public ResponseCustom<String> catchChatSelectNotFoundException(ChatSelectNotFoundException e) {
log.error(e.getMessage());
return ResponseCustom.NOT_FOUND(e.getMessage());
}

@ExceptionHandler(SelectTypeNotFoundException.class)
public ResponseCustom<String> catchSelectTypeNotFoundException(SelectTypeNotFoundException e) {
log.error(e.getMessage());
return ResponseCustom.NOT_FOUND(e.getMessage());
}
}

0 comments on commit bfe7194

Please sign in to comment.