Skip to content

Commit

Permalink
[BE/#29] Feat : 전역 에러 핸들러 추가
Browse files Browse the repository at this point in the history
- GlobalExceptionHandler
  • Loading branch information
MuseopKim committed Jun 15, 2020
1 parent cd789d2 commit 8617475
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.codesquad.issuetracker.ragdoll.exception;

import com.codesquad.issuetracker.ragdoll.commonconstant.ErrorMessages;
import com.codesquad.issuetracker.ragdoll.response.ApiResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

@ExceptionHandler(UserUnauthorizedException.class)
@ResponseBody
public ResponseEntity<ApiResponse<String>> handleUserUnauthorizeedException(UserUnauthorizedException userUnauthorizedException) {
return new ResponseEntity(ApiResponse.UNAUTHORIZED(ErrorMessages.USER_UNAUTHORIZED), HttpStatus.UNAUTHORIZED);
}
}

0 comments on commit 8617475

Please sign in to comment.