Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
isc-core
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
isc-v3.1-tmp
isc-core
Commits
b0a31abb
Commit
b0a31abb
authored
Sep 29, 2024
by
hulei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充全局异常处理
parent
606992d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
ISCExceptionHandler.java
...ava/com/brilliance/isc/exception/ISCExceptionHandler.java
+43
-0
No files found.
isc-common-service/src/main/java/com/brilliance/isc/exception/ISCExceptionHandler.java
0 → 100644
View file @
b0a31abb
package
com
.
brilliance
.
isc
.
exception
;
import
com.brilliance.isc.vo.ResponseSet
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
java.sql.SQLException
;
@RestControllerAdvice
public
class
ISCExceptionHandler
{
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@ExceptionHandler
(
SQLException
.
class
)
public
ResponseSet
handlerException
(
SQLException
e
)
{
logger
.
error
(
""
,
e
);
return
ResponseSet
.
fail
(
"SQL执行异常!"
);
}
@ExceptionHandler
(
Exception
.
class
)
public
ResponseSet
handlerException
(
Exception
e
)
{
logger
.
error
(
""
,
e
);
return
ResponseSet
.
fail
(
"接口执行异常!["
+
e
.
getMessage
()+
"]"
);
}
@ExceptionHandler
(
Throwable
.
class
)
public
ResponseSet
handlerException
(
Throwable
e
)
{
logger
.
error
(
""
,
e
);
return
ResponseSet
.
fail
(
"接口内部异常!["
+
e
.
getMessage
()+
"]"
);
}
@ExceptionHandler
(
RestBizException
.
class
)
public
ResponseSet
handlerException
(
RestBizException
e
)
{
logger
.
error
(
""
,
e
);
return
new
ResponseSet
(
e
.
getCode
(),
e
.
getMessage
());
}
}
Write
Preview
Markdown
is supported
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