Skip to content

Commit

Permalink
refactor: GlobalExceptionHandler 정리
Browse files Browse the repository at this point in the history
- 추가된 Exception handle 메서드 추가
  • Loading branch information
hoa0217 committed Mar 6, 2024
1 parent dd50f20 commit 5af787b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 62 deletions.
111 changes: 57 additions & 54 deletions src/main/java/com/modoospace/common/GlobalExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
package com.modoospace.common;

import com.modoospace.common.exception.AlarmSendException;
import com.modoospace.common.exception.ConflictingReservationException;
import com.modoospace.common.exception.ConflictingTimeException;
import com.modoospace.common.exception.DuplicatedWeekdayException;
import com.modoospace.common.exception.InvalidTimeRangeException;
import com.modoospace.common.exception.NotFoundEntityException;
import com.modoospace.common.exception.NotOpenedFacilityException;
import com.modoospace.common.exception.PermissionDeniedException;
import com.modoospace.common.exception.SSEConnectError;
import com.modoospace.common.exception.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
Expand All @@ -17,57 +9,68 @@
@RestControllerAdvice
public class GlobalExceptionHandler {

@ExceptionHandler(AlarmSendException.class)
public ResponseEntity<String> handleAlarmSendException(
InvalidTimeRangeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
@ExceptionHandler(AlarmSendException.class)
public ResponseEntity<String> handleAlarmSendException(InvalidTimeRangeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}

@ExceptionHandler(ConflictingReservationException.class)
public ResponseEntity<String> handleConflictingReservationException(
ConflictingReservationException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.CONFLICT);
}
@ExceptionHandler(SSEConnectError.class)
public ResponseEntity<String> handleSSEConnectError(SSEConnectError exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}

@ExceptionHandler(ConflictingTimeException.class)
public ResponseEntity<String> handleConflictingTimeException(
ConflictingTimeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.CONFLICT);
}
@ExceptionHandler(RedisProcessingException.class)
public ResponseEntity<String> handleRedisProcessingException(SSEConnectError exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}

@ExceptionHandler(DuplicatedWeekdayException.class)
public ResponseEntity<String> handleDuplicatedWeekdayException(
ConflictingTimeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.CONFLICT);
}
@ExceptionHandler(ConflictingReservationException.class)
public ResponseEntity<String> handleConflictingReservationException(ConflictingReservationException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.CONFLICT);
}

@ExceptionHandler(InvalidTimeRangeException.class)
public ResponseEntity<String> handleInvalidTimeRangeException(
InvalidTimeRangeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(ConflictingTimeException.class)
public ResponseEntity<String> handleConflictingTimeException(ConflictingTimeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.CONFLICT);
}

@ExceptionHandler(NotFoundEntityException.class)
public ResponseEntity<String> handleNotFoundEntityException(
NotFoundEntityException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.NOT_FOUND);
}
@ExceptionHandler(DuplicatedWeekdayException.class)
public ResponseEntity<String> handleDuplicatedWeekdayException(ConflictingTimeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.CONFLICT);
}

@ExceptionHandler(NotOpenedFacilityException.class)
public ResponseEntity<String> handleNotOpenedFacilityException(
NotOpenedFacilityException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(PermissionDeniedException.class)
public ResponseEntity<String> handlePermissionDeniedException(PermissionDeniedException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.FORBIDDEN);
}

@ExceptionHandler(PermissionDeniedException.class)
public ResponseEntity<String> handlePermissionDeniedException(
PermissionDeniedException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.FORBIDDEN);
}
@ExceptionHandler(NotFoundEntityException.class)
public ResponseEntity<String> handleNotFoundEntityException(NotFoundEntityException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.NOT_FOUND);
}

@ExceptionHandler(SSEConnectError.class)
public ResponseEntity<String> handleSSEConnectError(
SSEConnectError exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
@ExceptionHandler(InvalidTimeRangeException.class)
public ResponseEntity<String> handleInvalidTimeRangeException(InvalidTimeRangeException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(NotOpenedFacilityException.class)
public ResponseEntity<String> handleNotOpenedFacilityException(NotOpenedFacilityException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(DeleteSpaceWithFacilitiesException.class)
public ResponseEntity<String> handleDeleteSpaceWithFacilitiesException(DeleteSpaceWithFacilitiesException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(InvalidNumOfUserException.class)
public ResponseEntity<String> handleInvalidNumOfUserException(InvalidNumOfUserException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(LimitNumOfUserException.class)
public ResponseEntity<String> handleLimitNumOfUserException(LimitNumOfUserException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
}
}

This file was deleted.

0 comments on commit 5af787b

Please sign in to comment.