Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e9cd3989
authored
Jul 12, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add logs
1 parent
f6cdd0ef
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
project-gateway/src/main/java/com/dituhui/pea/gateway/handler/GlobalExceptionHandler.java
project-gateway/src/main/java/com/dituhui/pea/gateway/handler/GlobalExceptionHandler.java
View file @
e9cd398
package
com
.
dituhui
.
pea
.
gateway
.
handler
;
package
com
.
dituhui
.
pea
.
gateway
.
handler
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
java.util.Arrays
;
import
com.dituhui.pea.exception.BusinessException
;
import
com.dituhui.pea.gateway.config.AuthFilter
;
import
com.dituhui.pea.pojo.WebResult
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler
;
import
org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.core.annotation.Order
;
...
@@ -20,6 +11,15 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
...
@@ -20,6 +11,15 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import
org.springframework.web.server.ResponseStatusException
;
import
org.springframework.web.server.ResponseStatusException
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.handler.ResponseStatusExceptionHandler
;
import
org.springframework.web.server.handler.ResponseStatusExceptionHandler
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.exception.BusinessException
;
import
com.dituhui.pea.pojo.WebResult
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
/**
/**
...
@@ -53,7 +53,8 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler {
...
@@ -53,7 +53,8 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler {
StatusCodeEnum
codeEnum
=
((
BusinessException
)
ex
).
codeEnum
;
StatusCodeEnum
codeEnum
=
((
BusinessException
)
ex
).
codeEnum
;
return
bufferFactory
.
wrap
(
objectMapper
.
writeValueAsBytes
(
WebResult
.
failed
(
codeEnum
)));
return
bufferFactory
.
wrap
(
objectMapper
.
writeValueAsBytes
(
WebResult
.
failed
(
codeEnum
)));
}
else
{
}
else
{
log
.
error
(
"{} 访问网关异常:{} {}"
,
exchange
.
getRequest
().
getPath
(),
ex
,
ex
.
getMessage
());
log
.
error
(
"{} 访问网关异常:{} {}"
,
exchange
.
getRequest
().
getPath
(),
Arrays
.
toString
(
ex
.
getStackTrace
()),
ex
.
getMessage
());
return
bufferFactory
.
wrap
(
return
bufferFactory
.
wrap
(
objectMapper
.
writeValueAsBytes
(
WebResult
.
failed
(
StatusCodeEnum
.
SYSTEM_UNKNOWN_ERROR
)));
objectMapper
.
writeValueAsBytes
(
WebResult
.
failed
(
StatusCodeEnum
.
SYSTEM_UNKNOWN_ERROR
)));
}
}
...
...
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