|
@@ -32,31 +32,28 @@ public class GlobalExceptionHandler {
|
|
|
log.error("handler exception", e);
|
|
|
if (e instanceof NotLoginException) {
|
|
|
response.setStatus(401);
|
|
|
- return new RequestResult("401", "未授权的请求");
|
|
|
+ return new RequestResult(401, "未授权的请求");
|
|
|
}
|
|
|
|
|
|
if (e instanceof NotPermissionException || e instanceof NotRoleException) {
|
|
|
response.setStatus(403);
|
|
|
- return new RequestResult("403", "没有权限");
|
|
|
+ return new RequestResult(403, "没有权限");
|
|
|
}
|
|
|
|
|
|
if (e.getMessage().contains("Unauthorized")) {
|
|
|
response.setStatus(403);
|
|
|
- return new RequestResult("403", "没有权限");
|
|
|
+ return new RequestResult(403, "没有权限");
|
|
|
}
|
|
|
response.setStatus(500);
|
|
|
- return new RequestResult("500", e.getMessage());
|
|
|
+ return new RequestResult(500, e.getMessage());
|
|
|
}
|
|
|
|
|
|
@NoArgsConstructor
|
|
|
@AllArgsConstructor
|
|
|
@Data
|
|
|
public static class RequestResult {
|
|
|
-
|
|
|
- private String code;
|
|
|
-
|
|
|
+ private int code;
|
|
|
private String message;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|