Oauth2ExceptionHandler.java 672 B

1234567891011121314151617181920
  1. package com.huimv.oauth2.exception;
  2. import com.macro.cloud.api.CommonResult;
  3. import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
  4. import org.springframework.web.bind.annotation.ControllerAdvice;
  5. import org.springframework.web.bind.annotation.ExceptionHandler;
  6. import org.springframework.web.bind.annotation.ResponseBody;
  7. /**
  8. * 全局处理Oauth2抛出的异常
  9. * Created by macro on 2020/7/17.
  10. */
  11. @ControllerAdvice
  12. public class Oauth2ExceptionHandler {
  13. @ResponseBody
  14. @ExceptionHandler(value = OAuth2Exception.class)
  15. public CommonResult handleOauth2(OAuth2Exception e) {
  16. return CommonResult.failed(e.getMessage());
  17. }
  18. }