|
@@ -1,7 +1,6 @@
|
|
|
-package com.mooctest.crowd.site.controller.advice;
|
|
|
+package com.mooctest.controller.advice;
|
|
|
|
|
|
-import com.mooctest.crowd.domain.exception.*;
|
|
|
-import com.mooctest.crowd.site.constants.ResponseConstant;
|
|
|
+import com.mooctest.exception.BaseException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|
@@ -23,63 +22,20 @@ public class ExceptionAdvice {
|
|
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
|
public String handleException(Exception e){
|
|
|
log.error("访问出错:"+e.getMessage(), e);
|
|
|
- if (e instanceof AccountNotExistException){
|
|
|
- return ResponseConstant.USER_NOT_EXISTS;
|
|
|
- } else if (e instanceof NullPointerException){
|
|
|
- return "操作失败";
|
|
|
- } else if (e instanceof CrowdTestProjectNotExistException){
|
|
|
- return "项目不存在";
|
|
|
- } else if (e instanceof CrowdTestTaskNotExistException){
|
|
|
- return "任务不存在";
|
|
|
- } else if (e instanceof CrowdTestReportNotExistException){
|
|
|
- return "报告不存在";
|
|
|
- } else if (e instanceof CrowdTestTaskNoPriceException){
|
|
|
- return "项目未设置价格";
|
|
|
- } else if (e instanceof PasswordErrorException){
|
|
|
- return "密码错误";
|
|
|
- } else if (e instanceof ApplicationTypeNoExistException){
|
|
|
- return "应用类型不存在";
|
|
|
- } else if (e instanceof TestTypeNoExistException){
|
|
|
- return "服务类型不存在";
|
|
|
- } else if (e instanceof ApplicationTypeToTestTypeNoExistException){
|
|
|
- return "应用类型对应的测试类型不存在";
|
|
|
- } else if (e instanceof FieldNoExistException){
|
|
|
- return "领域不存在";
|
|
|
- } else if (e instanceof ResourceNoExistException){
|
|
|
- return "资源不存在";
|
|
|
- } else if (e instanceof UserTaskCountNoExistException) {
|
|
|
- return "当前用户没有参与接包";
|
|
|
- } else if (e instanceof HaveNotAgencyAuthException){
|
|
|
- return "您未认证为接包用户,请认证后操作。";
|
|
|
- } else if (e instanceof HaveNotPartAuthException){
|
|
|
- return "您未认证为发包用户,请认证后操作。";
|
|
|
- } else if(e instanceof CrowdTestEndPointException){
|
|
|
- return "任务的服务序列号输入有误,不是base64加密后的序列号。";
|
|
|
- } else if(e instanceof ExportTaskFileNotExistException){
|
|
|
- return "导出的任务文件不存在。";
|
|
|
- } else if(e instanceof ExportTaskFileDirectoryNotExistException){
|
|
|
- return "导出的任务文件所在的文件夹不存在。";
|
|
|
- } else if(e instanceof FileIsEmptyException){
|
|
|
- return "文件不存在或文件是空文件,请重新上传。";
|
|
|
- } else if(e instanceof FileCopyException){
|
|
|
- return "复制文件错误。";
|
|
|
- } else if(e instanceof FileDownloadException){
|
|
|
- return "文件下载失败。";
|
|
|
- } else if(e instanceof FileUploadFailureException){
|
|
|
- return "文件上传失败。";
|
|
|
- } else if(e instanceof IllegalStateUploadException){
|
|
|
- return "文件上传失败,由于存在部分分片未上传完成。";
|
|
|
- } else {
|
|
|
- return e.getMessage();
|
|
|
- }
|
|
|
+// if (e instanceof ConfigurationNotExistException){
|
|
|
+// return "";
|
|
|
+// } else {
|
|
|
+// return e.getMessage();
|
|
|
+// }
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
- @ExceptionHandler(UnauthorizedException.class)
|
|
|
- @ResponseStatus(HttpStatus.UNAUTHORIZED)
|
|
|
- public String handleUnauthorized(UnauthorizedException e){
|
|
|
- log.info("401:未经认证的请求");
|
|
|
- return e.getMessage();
|
|
|
- }
|
|
|
+// @ExceptionHandler(UnauthorizedException.class)
|
|
|
+// @ResponseStatus(HttpStatus.UNAUTHORIZED)
|
|
|
+// public String handleUnauthorized(UnauthorizedException e){
|
|
|
+// log.info("401:未经认证的请求");
|
|
|
+// return e.getMessage();
|
|
|
+// }
|
|
|
|
|
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
|
|
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
|
@@ -93,14 +49,13 @@ public class ExceptionAdvice {
|
|
|
@ResponseBody
|
|
|
public String handleSystemException(Exception e){
|
|
|
log.error("System Error: "+e.getMessage(), e);
|
|
|
-// return "系统异常 " + e.getMessage();
|
|
|
return e.getMessage();
|
|
|
}
|
|
|
|
|
|
- @ExceptionHandler(Excel2ProjectException.class)
|
|
|
- @ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
|
- public String handleExcel2ProjectException(Excel2ProjectException e){
|
|
|
- log.error("Excel表中存在错误:"+e.getErrorLogs());
|
|
|
- return "Excel表中存在错误:"+ e.getErrorLogs();
|
|
|
- }
|
|
|
+// @ExceptionHandler(Excel2ProjectException.class)
|
|
|
+// @ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
|
+// public String handleExcel2ProjectException(Excel2ProjectException e){
|
|
|
+// log.error("Excel表中存在错误:"+e.getErrorLogs());
|
|
|
+// return "Excel表中存在错误:"+ e.getErrorLogs();
|
|
|
+// }
|
|
|
}
|