-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
calendar 관련 예외처리
- Loading branch information
Showing
16 changed files
with
345 additions
and
71 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
36 changes: 36 additions & 0 deletions
36
JWT/src/main/java/JWTLogIn/JWT/user/advice/EventControllerAdvice.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,36 @@ | ||
package JWTLogIn.JWT.user.advice; | ||
|
||
import JWTLogIn.JWT.user.dto.error.ErrorResultDTO; | ||
import JWTLogIn.JWT.user.exception.BadRequestException; | ||
import JWTLogIn.JWT.user.exception.NotFoundException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice(basePackages = "JWTLogIn.JWT.user.controller") | ||
public class EventControllerAdvice { | ||
|
||
@ExceptionHandler(NotFoundException.class) | ||
public ResponseEntity<ErrorResultDTO> notFoundExHandler(NotFoundException e){ | ||
ErrorResultDTO errorResult = new ErrorResultDTO("NOT_FOUND", e.getMessage()); | ||
return new ResponseEntity<>(errorResult, HttpStatus.NOT_FOUND); | ||
} | ||
|
||
@ExceptionHandler(BadRequestException.class) | ||
public ResponseEntity<ErrorResultDTO> badRequestException(BadRequestException e) { | ||
ErrorResultDTO errorResult = new ErrorResultDTO("BAD_REQUEST", e.getMessage()); | ||
return new ResponseEntity<>(errorResult, HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | ||
@ExceptionHandler | ||
public ResponseEntity<ErrorResultDTO> baseException(Exception e){ | ||
ErrorResultDTO errorResult = new ErrorResultDTO("INTERNAL_SERVER_ERROR", e.getMessage()); | ||
return new ResponseEntity<>(errorResult, HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
} | ||
|
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
11 changes: 11 additions & 0 deletions
11
JWT/src/main/java/JWTLogIn/JWT/user/dto/error/ErrorResultDTO.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,11 @@ | ||
package JWTLogIn.JWT.user.dto.error; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class ErrorResultDTO { | ||
private String code; | ||
private String message; | ||
} |
25 changes: 25 additions & 0 deletions
25
JWT/src/main/java/JWTLogIn/JWT/user/dto/event/EventBriefDTO.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,25 @@ | ||
package JWTLogIn.JWT.user.dto.event; | ||
|
||
import JWTLogIn.JWT.user.entity.Enum.EventType; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class EventBriefDTO { | ||
private String title; | ||
private LocalDateTime startDate; | ||
private LocalDateTime endDate; | ||
private EventType eventType; | ||
@Builder | ||
public EventBriefDTO(String title, LocalDateTime startDate, LocalDateTime endDate, EventType eventType) { | ||
this.title = title; | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
this.eventType = eventType; | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
JWT/src/main/java/JWTLogIn/JWT/user/exception/BadRequestException.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,29 @@ | ||
package JWTLogIn.JWT.user.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ResponseStatus(code= HttpStatus.BAD_REQUEST) | ||
public class BadRequestException extends RuntimeException{ | ||
|
||
public BadRequestException() { | ||
super(); | ||
} | ||
|
||
public BadRequestException(String message) { | ||
super(message); | ||
} | ||
|
||
public BadRequestException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public BadRequestException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
protected BadRequestException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
|
||
} |
Oops, something went wrong.