mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-02 13:34:07 +08:00
exception optimization
This commit is contained in:
@ -106,7 +106,7 @@ public class Chat2dbWebMvcConfigurer implements WebMvcConfigurer {
|
||||
String path = SaHolder.getRequest().getRequestPath();
|
||||
if (path.startsWith(API_PREFIX)) {
|
||||
response.getWriter().println(JSON.toJSONString(
|
||||
ActionResult.fail("common.needLoggedIn", I18nUtils.getMessage("common.needLoggedIn"))));
|
||||
ActionResult.fail("common.needLoggedIn", I18nUtils.getMessage("common.needLoggedIn"), "")));
|
||||
return false;
|
||||
} else {
|
||||
throw new RedirectBusinessException(
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ai.chat2db.server.start.exception.convertor;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
import org.springframework.validation.BindException;
|
||||
|
||||
/**
|
||||
@ -13,6 +14,6 @@ public class BindExceptionConvertor implements ExceptionConvertor<BindException>
|
||||
@Override
|
||||
public ActionResult convert(BindException exception) {
|
||||
String message = ExceptionConvertorUtils.buildMessage(exception.getBindingResult());
|
||||
return ActionResult.fail("common.paramError", message);
|
||||
return ActionResult.fail("common.paramError", message, ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package ai.chat2db.server.start.exception.convertor;
|
||||
import ai.chat2db.server.tools.base.excption.BusinessException;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.server.tools.common.util.I18nUtils;
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
|
||||
/**
|
||||
* BusinessException
|
||||
@ -13,6 +14,6 @@ public class BusinessExceptionConvertor implements ExceptionConvertor<BusinessEx
|
||||
|
||||
@Override
|
||||
public ActionResult convert(BusinessException exception) {
|
||||
return ActionResult.fail(exception.getCode(), I18nUtils.getMessage(exception.getCode()));
|
||||
return ActionResult.fail(exception.getCode(), I18nUtils.getMessage(exception.getCode()), ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package ai.chat2db.server.start.exception.convertor;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.server.tools.common.util.I18nUtils;
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
|
||||
/**
|
||||
* 默认的异常处理
|
||||
@ -13,6 +14,6 @@ public class DefaultExceptionConvertor implements ExceptionConvertor<Throwable>
|
||||
|
||||
@Override
|
||||
public ActionResult convert(Throwable exception) {
|
||||
return ActionResult.fail("common.systemError", I18nUtils.getMessage("common.systemError"));
|
||||
return ActionResult.fail("common.systemError", I18nUtils.getMessage("common.systemError"), ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package ai.chat2db.server.start.exception.convertor;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
|
||||
import ai.chat2db.server.tools.common.util.I18nUtils;
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
|
||||
/**
|
||||
@ -14,6 +15,6 @@ public class MaxUploadSizeExceededExceptionConvertor implements ExceptionConvert
|
||||
|
||||
@Override
|
||||
public ActionResult convert(MaxUploadSizeExceededException exception) {
|
||||
return ActionResult.fail("common.maxUploadSize", I18nUtils.getMessage("common.maxUploadSize"));
|
||||
return ActionResult.fail("common.maxUploadSize", I18nUtils.getMessage("common.maxUploadSize"), ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package ai.chat2db.server.start.exception.convertor;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
|
||||
/**
|
||||
@ -14,6 +15,6 @@ public class MethodArgumentNotValidExceptionConvertor implements ExceptionConver
|
||||
@Override
|
||||
public ActionResult convert(MethodArgumentNotValidException exception) {
|
||||
String message = ExceptionConvertorUtils.buildMessage(exception.getBindingResult());
|
||||
return ActionResult.fail("common.paramError", message);
|
||||
return ActionResult.fail("common.paramError", message, ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package ai.chat2db.server.start.exception.convertor;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
|
||||
import ai.chat2db.server.tools.common.util.I18nUtils;
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
/**
|
||||
@ -15,6 +16,6 @@ public class MethodArgumentTypeMismatchExceptionConvertor
|
||||
|
||||
@Override
|
||||
public ActionResult convert(MethodArgumentTypeMismatchException exception) {
|
||||
return ActionResult.fail("common.paramError", I18nUtils.getMessage("common.paramError"));
|
||||
return ActionResult.fail("common.paramError", I18nUtils.getMessage("common.paramError"), ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ai.chat2db.server.start.exception.convertor;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.spi.util.ExceptionUtils;
|
||||
|
||||
/**
|
||||
* 参数异常 目前包括
|
||||
@ -14,6 +15,6 @@ public class ParamExceptionConvertor implements ExceptionConvertor<Throwable> {
|
||||
|
||||
@Override
|
||||
public ActionResult convert(Throwable exception) {
|
||||
return ActionResult.fail("common.paramError", exception.getMessage());
|
||||
return ActionResult.fail("common.paramError", exception.getMessage(), ExceptionUtils.getErrorInfoFromException(exception));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user