Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d2b6f357
authored
Apr 28, 2021
by
fz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.添加车钥匙异常处理
1 parent
24e6cb78
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
src/main/java/com/glsx/smart/exception/CarKeyException.java
src/main/java/com/glsx/smart/exception/GlobalExceptionHandler.java
src/main/java/com/glsx/smart/exception/CarKeyException.java
0 → 100644
View file @
d2b6f35
package
com
.
glsx
.
smart
.
exception
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
CarKeyException
extends
RuntimeException
{
private
Integer
code
;
private
String
message
;
public
CarKeyException
()
{}
public
CarKeyException
(
ResultEnum
resultEnum
)
{
this
.
code
=
resultEnum
.
getCode
();
this
.
message
=
resultEnum
.
getMessage
();
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
static
CarKeyException
create
(
int
code
,
String
message
){
CarKeyException
businessException
=
new
CarKeyException
();
businessException
.
code
=
code
;
businessException
.
message
=
message
;
return
businessException
;
}
public
static
CarKeyException
create
(
ResultEnum
resultEnum
)
{
return
create
(
resultEnum
.
getCode
(),
resultEnum
.
getMessage
());
}
}
src/main/java/com/glsx/smart/exception/GlobalExceptionHandler.java
View file @
d2b6f35
...
@@ -25,6 +25,12 @@ public class GlobalExceptionHandler {
...
@@ -25,6 +25,12 @@ public class GlobalExceptionHandler {
return
R
.
error
(
e
.
getMessage
());
return
R
.
error
(
e
.
getMessage
());
}
}
@ExceptionHandler
({
CarKeyException
.
class
})
public
R
handleCarKeyException
(
CarKeyException
e
)
{
log
.
error
(
"车钥匙异常"
,
e
);
return
R
.
error
(
e
.
getCode
(),
e
.
getMessage
());
}
@ExceptionHandler
({
ServletRequestBindingException
.
class
,
MethodArgumentNotValidException
.
class
,
@ExceptionHandler
({
ServletRequestBindingException
.
class
,
MethodArgumentNotValidException
.
class
,
BindException
.
class
})
BindException
.
class
})
public
R
handleBindException
(
Exception
e
)
{
public
R
handleBindException
(
Exception
e
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment