Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
a0d0dd13
Commit
a0d0dd13
authored
May 13, 2023
by
macro
Browse files
全局异常处理逻辑完善
parent
137e1510
Changes
1
Hide whitespace changes
Inline
Side-by-side
mall-common/src/main/java/com/macro/mall/common/exception/GlobalExceptionHandler.java
View file @
a0d0dd13
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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment