mirror of https://gitee.com/xiaonuobase/snowy
【更新】完善异常处理
parent
959dea0f8c
commit
6f67b0f433
|
@ -12,9 +12,6 @@
|
||||||
*/
|
*/
|
||||||
package vip.xiaonuo.common.util;
|
package vip.xiaonuo.common.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import vip.xiaonuo.common.exception.CommonException;
|
|
||||||
|
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
|
|
||||||
|
@ -35,11 +32,7 @@ public class CommonFilterExceptionUtil {
|
||||||
**/
|
**/
|
||||||
public static void handleFilterException(ServletRequest request, ServletResponse response, Exception e) {
|
public static void handleFilterException(ServletRequest request, ServletResponse response, Exception e) {
|
||||||
try {
|
try {
|
||||||
if(ObjectUtil.isNotEmpty(e.getMessage())) {
|
request.setAttribute("model", e);
|
||||||
request.setAttribute("model", new CommonException(e.getMessage()));
|
|
||||||
} else {
|
|
||||||
request.setAttribute("model", e);
|
|
||||||
}
|
|
||||||
request.getRequestDispatcher("/errorView").forward(request, response);
|
request.getRequestDispatcher("/errorView").forward(request, response);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class GlobalErrorViewController {
|
||||||
} else {
|
} else {
|
||||||
commonResult = CommonResult.error();
|
commonResult = CommonResult.error();
|
||||||
}
|
}
|
||||||
|
Exception exception = (Exception) model;
|
||||||
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
log.error(">>> {}", commonResult.getMsg());
|
log.error(">>> {}", commonResult.getMsg());
|
||||||
return commonResult;
|
return commonResult;
|
||||||
|
|
Loading…
Reference in New Issue