|
|
@@ -1,5 +1,7 @@
|
|
|
package com.nju.edu.pay.handler;
|
|
|
|
|
|
+import cn.dev33.satoken.exception.NotLoginException;
|
|
|
+import cn.dev33.satoken.exception.NotPermissionException;
|
|
|
import cn.dev33.satoken.exception.SaTokenException;
|
|
|
import com.seecoder.commoncore.util.Response;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
@@ -11,6 +13,21 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
public class GlobalExceptionHandler {
|
|
|
@ExceptionHandler(SaTokenException.class)
|
|
|
@ResponseStatus(HttpStatus.FORBIDDEN)
|
|
|
+ public Response<String> handleException(SaTokenException ste){
|
|
|
+ ste.printStackTrace();
|
|
|
+ if(ste instanceof NotPermissionException){
|
|
|
+ return Response.failed("NOT_PERMISSION",ste.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ste instanceof NotLoginException){
|
|
|
+ return Response.failed("NOT_LOGIN",ste.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return Response.failed(ste.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ExceptionHandler(Exception.class)
|
|
|
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
|
public Response<String> handleException(Exception e){
|
|
|
e.printStackTrace();
|
|
|
return Response.failed(e.getMessage());
|