package com.interplug.qcast.config.Exception; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; @Slf4j @ControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(HttpRequestMethodNotSupportedException.class) protected ResponseEntity handle(HttpRequestMethodNotSupportedException e) { return ResponseEntity.badRequest() .body(ErrorResponse.of(ErrorCode.METHOD_NOT_ALLOWED.getMessage())); } @ExceptionHandler(BaseException.class) protected ResponseEntity handle(BaseException e) { final ErrorCode errorCode = e.getErrorCode(); return ResponseEntity.status(errorCode.getStatus()) .body(ErrorResponse.of(errorCode.getMessage())); } @ExceptionHandler(Exception.class) protected ResponseEntity handle(Exception e) { return ResponseEntity.internalServerError() .body(ErrorResponse.of(ErrorCode.INTERNAL_SERVER_ERROR.getMessage())); } }