-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: exception enum 클래스 추가 * feat: controller advice 추가 * feat: member domain 권한 초기화
- Loading branch information
Showing
30 changed files
with
464 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
src/main/java/com/ohdab/classroom/exception/ContentOverflowException.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.ohdab.core.exception; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum ExceptionEnum { | ||
|
||
// 600 - classroom | ||
NO_CLASSROOM(600, "존재하지 않는 교실입니다."), | ||
NO_GRADE(601, "존재하지 않는 학년입니다."), | ||
NO_STUDENT(602, "존재하지 않는 학생입니다."), | ||
NO_TEACHER(603, "존재하지 않는 선생님입니다."), | ||
|
||
// 700 - member | ||
ALREADY_WITHDRAWL(700, "이미 탈퇴한 계정입니다."), | ||
DUPLICATED_MEMBER(701, "이미 존재하는 회원입니다."), | ||
NO_MEMBER(702, "존재하지 않는 회원입니다."), | ||
MEMBER_CONTENT_OVERFLOW(703, "최대 글자수를 초과했습니다."), | ||
NO_AUTHORITY(704, "권한정보가 누락되었습니다."), | ||
|
||
// 800 - mistakeNote | ||
NO_MISTAKE_NOTE(800, "존재하지 않는 오답노트입니다."), | ||
NO_NUMBERS_WRONG_N_TIMES(801, ""), | ||
NUMBER_IS_OUT_OF_RANGE(802, "N번 이상 틀린 문제가 없습니다."), | ||
MISTAKE_NUMBERS_SIZE(803, "기록 가능한 문제수를 초과했습니다."), | ||
|
||
// 900 - workbook | ||
WORKBOOK_CONTENT_OVERFLOW(900, "최대 글자수를 초과했습니다."), | ||
DUPLICATED_WORKBOOK(901, "이미 존재하는 교재입니다."), | ||
INVALID_WORKBOOK_NUMBER_RANGE(902, "허용 범위를 벗어난 문제 번호입니다."), | ||
NO_WORKBOOK(903, "존재하지 않는 교재입니다."), | ||
|
||
// 1000 - null | ||
IS_NULL(1000, "필수 입력값이 누락되었습니다."), | ||
; | ||
|
||
private int errorCode; | ||
private String message; | ||
|
||
ExceptionEnum(int errorCode, String message) { | ||
this.errorCode = errorCode; | ||
this.message = message; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/ohdab/core/exception/handler/ClassroomExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.ohdab.core.exception.handler; | ||
|
||
import com.ohdab.classroom.exception.NoClassroomException; | ||
import com.ohdab.classroom.exception.NoGradeException; | ||
import com.ohdab.classroom.exception.NoStudentException; | ||
import com.ohdab.classroom.exception.NoTeacherException; | ||
import com.ohdab.core.exception.ExceptionEnum; | ||
import com.ohdab.core.template.ErrorMessage; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class ClassroomExceptionHandler { | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ErrorMessage> noClassroomException(NoClassroomException e) { | ||
return ResponseEntity.badRequest() | ||
.body( | ||
ErrorMessage.builder() | ||
.errorCode(ExceptionEnum.NO_CLASSROOM.getErrorCode()) | ||
.message(e.getMessage()) | ||
.build()); | ||
} | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ErrorMessage> noGradeException(NoGradeException e) { | ||
return ResponseEntity.badRequest() | ||
.body( | ||
ErrorMessage.builder() | ||
.errorCode(ExceptionEnum.NO_GRADE.getErrorCode()) | ||
.message(e.getMessage()) | ||
.build()); | ||
} | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ErrorMessage> noStudentException(NoStudentException e) { | ||
return ResponseEntity.badRequest() | ||
.body( | ||
ErrorMessage.builder() | ||
.errorCode(ExceptionEnum.NO_STUDENT.getErrorCode()) | ||
.message(e.getMessage()) | ||
.build()); | ||
} | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ErrorMessage> noTeacherException(NoTeacherException e) { | ||
return ResponseEntity.badRequest() | ||
.body( | ||
ErrorMessage.builder() | ||
.errorCode(ExceptionEnum.NO_TEACHER.getErrorCode()) | ||
.message(e.getMessage()) | ||
.build()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/ohdab/core/exception/handler/CommonExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.ohdab.core.exception.handler; | ||
|
||
import com.ohdab.core.exception.ExceptionEnum; | ||
import com.ohdab.core.template.ErrorMessage; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class CommonExceptionHandler { | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ErrorMessage> illegalArgumentException(IllegalArgumentException e) { | ||
return ResponseEntity.badRequest() | ||
.body( | ||
ErrorMessage.builder() | ||
.errorCode(ExceptionEnum.IS_NULL.getErrorCode()) | ||
.message(e.getMessage()) | ||
.build()); | ||
} | ||
} |
Oops, something went wrong.