Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : 전역적 예외처리 로직 생성 및 Success,ErrorResponse 리팩토링 #14

Merged
merged 18 commits into from
Aug 5, 2024

Conversation

j2noo
Copy link
Collaborator

@j2noo j2noo commented Aug 4, 2024

개발 내용

  • RacingGameWinner 테이블의 rank 컬럼이 예약어여서 임시로 ranking 으로 수정
  • http요청에 대한 응답에 관한 정보를 BaseCode, SuccessCode, ErrorCode에서 관리
  • http요청에 대해, 본문에 담을 응답을 BaseResponse, SuccessResponse, ErrorResponse 클래스에서 관리
  • 비즈니스 로직에서 발생할 수 있는 에러를 GlobalException에서 발생시킴.
  • GlobalExceptionHandler에서 발생한 에러를 캐치하여 ErrorResponse로 반환
  • 추후 개발 과정에서 각 도메인별로 {Domain}Exception{Domain}ExceptionHandler를 생성하여 도메인 별로 에러를 관리할 것

@j2noo j2noo added 진우 feat📌 기능 개발 labels Aug 4, 2024
@j2noo j2noo requested a review from putdata August 4, 2024 04:50
@j2noo j2noo self-assigned this Aug 4, 2024
Copy link
Collaborator

@putdata putdata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컨벤션 관련해서만 고쳐주시면 될 것 같아요.

public class HealthTestController {
@GetMapping("/api/health")
public ResponseEntity<SuccessResponse<String>> healthTest() {
return ResponseEntity.ok(new SuccessResponse<>(1000,"api health test에 성공했습니다.","health test v1"));
return SuccessResponse.of(SuccessCode.OK,"Caecae Spring Server Health Test ~!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,와 "사이에 공백 넣어주세요

public class ErrorResponse extends BaseResponse {

private ErrorResponse(ErrorCode errorCode) {
super(errorCode.getResponseCode(),errorCode.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,와 "사이에 공백 넣어주세요

*/
@Getter
@AllArgsConstructor(access = AccessLevel.PROTECTED)
public enum ErrorCode implements BaseCode{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseCode와 { 사이에 공백 넣어주세요.

/**
* 1000 : 틀린그림찾기
*/
NOT_FOUND(1000, "잘못된 요청입니다.",HttpStatus.NOT_FOUND),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,와 "사이에 공백 넣어주세요

/**
* 2xxx : 레이싱게임 ..
*/
NEED_AUTHENICATE(1000, "권한이 필요한 요청입니다,",HttpStatus.UNAUTHORIZED),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,와 "사이에 공백 넣어주세요

*/
@Getter
@AllArgsConstructor(access = AccessLevel.PROTECTED)
public enum SuccessCode implements BaseCode{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseCode와 { 사이에 공백 넣어주세요.

/**
* 1000 : 틀린그림찾기
*/
OK(1000, "요청이 성공했습니다.",HttpStatus.OK),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,와 "사이에 공백 넣어주세요

CREATED(1001,"생성 요청이 성공했습니다.",HttpStatus.CREATED),
USER_CREATED(1001,"유저 회원가입이 성공했습니다.",HttpStatus.CREATED),
TEAM_CREATED(1001,"팀 등록에 성공했습니다.",HttpStatus.CREATED);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,와 "사이에 공백 넣어주세요

super(errorCode.getMessage());
this.errorCode = errorCode;


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 라인은 제거해주세요.

super(errorCode.getMessage());
this.errorCode = errorCode;


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 라인은 제거해주세요.

j2noo added 7 commits August 5, 2024 10:35
…#13)

* test : 서버 health check 컨트롤러 테스트 코드 작성 (CC-111)

* test : 서버 health check 컨트롤러 테스트 코드 작성 (CC-111)

* test : 서버 health check 컨트롤러 테스트 코드 작성 (CC-111)

* feat : S3 컨트롤러에 responseEntity 설정 (CC-111)

* test : S3 통합테스트 환경 disabled (CC-111)

* docs : Pull Request template 업로드 (CC-111)

* rename : S3 controller 디렉터리 수정
(CC-111)
@putdata putdata merged commit 576a082 into develop Aug 5, 2024
1 check passed
@putdata putdata deleted the CC-114 branch August 5, 2024 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat📌 기능 개발 진우
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants