Commit a0d0dd13 authored by macro's avatar macro
Browse files

全局异常处理逻辑完善

parent 137e1510
package com.macro.mall.common.exception;
import cn.hutool.core.util.StrUtil;
import com.macro.mall.common.api.CommonResult;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
......@@ -9,6 +10,8 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import java.sql.SQLSyntaxErrorException;
/**
* 全局异常处理类
* Created by macro on 2020/2/27.
......@@ -52,4 +55,14 @@ public class GlobalExceptionHandler {
}
return CommonResult.validateFailed(message);
}
@ResponseBody
@ExceptionHandler(value = SQLSyntaxErrorException.class)
public CommonResult handleSQLSyntaxErrorException(SQLSyntaxErrorException e) {
String message = e.getMessage();
if (StrUtil.isNotEmpty(message) && message.contains("denied")) {
message = "演示环境暂无修改权限,如需修改数据可本地搭建后台服务!";
}
return CommonResult.failed(message);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment