Created
May 8, 2020 16:03
-
-
Save ppyong/4d47f6546fbfa38d0af769e8f6099d73 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Order(0) | |
@RestControllerAdvice(annotations = RestController.class) | |
public class GlobalRestControllerAdvice { | |
@ExceptionHandler(Exception.class) | |
public Map<String, Object> handleException(Exception e){ | |
Map<String, Object> errorMap = new HashMap<>(); | |
errorMap.put("code", "E001"); | |
errorMap.put("message", "에러 발생했어요"); | |
return errorMap; | |
} | |
} | |
@Order(1) | |
@ControllerAdvice(annotations = Controller.class) | |
public class GlobalControllerAdvice { | |
@ExceptionHandler(Exception.class) | |
public String handleException(Exception e){ | |
return "error"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment