|  | @@ -4,9 +4,11 @@ package com.hwrj.cloud.common.exception;
 | 
	
		
			
				|  |  |  import com.hwrj.cloud.common.api.CommonResult;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | +import org.springframework.security.core.userdetails.UsernameNotFoundException;
 | 
	
		
			
				|  |  |  import org.springframework.validation.BindException;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.MethodArgumentNotValidException;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.ExceptionHandler;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.ResponseBody;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.RestControllerAdvice;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -53,4 +55,21 @@ public class GlobalExceptionHandler {
 | 
	
		
			
				|  |  |      public CommonResult businessException(GlobalException e){
 | 
	
		
			
				|  |  |           return CommonResult.failed(e.getMessage());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 处理自定义异常
 | 
	
		
			
				|  |  | +     * @param ex
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @ExceptionHandler(RuntimeException.class)
 | 
	
		
			
				|  |  | +    @ResponseBody
 | 
	
		
			
				|  |  | +    public CommonResult handleOrderException(RuntimeException ex) {
 | 
	
		
			
				|  |  | +        return CommonResult.failed(500 ,ex.getMessage());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ExceptionHandler(UsernameNotFoundException.class)
 | 
	
		
			
				|  |  | +    @ResponseBody
 | 
	
		
			
				|  |  | +    public CommonResult usernameNotFoundException(UsernameNotFoundException ex) {
 | 
	
		
			
				|  |  | +        return CommonResult.failed(400 ,ex.getMessage());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |